MediaWiki  REL1_19
ApiQuery Class Reference

This is the main query class. More...

Inheritance diagram for ApiQuery:
Collaboration diagram for ApiQuery:

List of all members.

Public Member Functions

 __construct ($main, $action)
 execute ()
 Query execution happens in the following steps: #1 Create a PageSet object with any pages requested by the user #2 If using a generator, execute it to get a new ApiPageSet object #3 Instantiate all requested modules.
 getAllowedParams ()
 Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (array with PARAM_* constants as keys) Don't call this function directly: use getFinalParams() to allow hooks to modify parameters as needed.
 getCustomPrinter ()
 If the module may only be used with a certain format module, it should override this method to return an instance of that formatter.
 getDB ()
 Gets a default slave database connection object.
 getDescription ()
 Returns the description string for this module.
 getExamples ()
 Returns usage examples for this module.
 getHelpUrls ()
 getModules ()
 Get the array mapping module names to class names.
 getModuleType ($moduleName)
 Get whether the specified module is a prop, list or a meta query module.
 getNamedDB ($name, $db, $groups)
 Get the query database connection with the given name.
 getPageSet ()
 Gets the set of pages the user has requested (or generated)
 getParamDescription ()
 Returns an array of parameter descriptions.
 getPossibleErrors ()
 Returns a list of all possible errors returned by the module.
 getVersion ()
 Returns a string that identifies the version of the extending class.
 makeHelpMsg ()
 Override the parent to generate help messages for all available query modules.
 makeHelpMsgParameters ()
 Override to add extra parameters from PageSet.
 newGenerator ($generatorName)
 Create a generator object of the given type and return it.
 shouldCheckMaxlag ()
 Indicates if this module needs maxlag to be checked.

Public Attributes

 $convertTitles
 $iwUrl
 $mListModuleNames
 $mMetaModuleNames
 $redirects

Protected Member Functions

 executeGeneratorModule ($generator, $modules)
 For generator mode, execute generator, and use its output as new ApiPageSet.
 mergeCacheMode ($cacheMode, $modCacheMode)
 Update a cache mode string, applying the cache mode of a new module to it.

Protected Attributes

 $mAllowedGenerators = array()

Private Member Functions

 addCustomFldsToPageSet ($modules, $pageSet)
 Query modules may optimize data requests through the $this->getPageSet() object by adding extra fields from the page table.
 doExport ($pageSet, $result)
 instantiateModules (&$modules, $param, $moduleList)
 Create instances of all modules requested by the client.
 makeHelpMsgHelper ($moduleList, $paramName)
 For all modules in $moduleList, generate help messages and join them together.
 outputGeneralPageInfo ()
 Appends an element for each page in the current pageSet with the most general information (id, title), plus any title normalizations and missing or invalid title/pageids/revids.

Static Private Member Functions

static appendUserModules (&$modules, $newModules)
 Helper function to append any add-in modules to the list.

Private Attributes

 $mNamedDB = array()
 $mPageSet
 $mPropModuleNames
 $mQueryListModules
 $mQueryMetaModules
 $mQueryPropModules
 $mSlaveDB = null
 $params

Detailed Description

This is the main query class.

It behaves similar to ApiMain: based on the parameters given, it will create a list of titles to work on (an ApiPageSet object), instantiate and execute various property/list/meta modules, and assemble all resulting data into a single ApiResult object.

In generator mode, a generator will be executed first to populate a second ApiPageSet object, and that object will be used for all subsequent modules.

Definition at line 38 of file ApiQuery.php.


Constructor & Destructor Documentation

ApiQuery::__construct ( main,
action 
)

Definition at line 106 of file ApiQuery.php.

References $wgAPIListModules, $wgAPIMetaModules, $wgAPIPropModules, appendUserModules(), and makeHelpMsgHelper().

Here is the call graph for this function:


Member Function Documentation

ApiQuery::addCustomFldsToPageSet ( modules,
pageSet 
) [private]

Query modules may optimize data requests through the $this->getPageSet() object by adding extra fields from the page table.

This function will gather all the extra request fields from the modules.

Parameters:
$modulesarray of module objects
$pageSetApiPageSet

Definition at line 304 of file ApiQuery.php.

Referenced by execute(), and executeGeneratorModule().

Here is the caller graph for this function:

static ApiQuery::appendUserModules ( &$  modules,
newModules 
) [static, private]

Helper function to append any add-in modules to the list.

Parameters:
$modulesarray Module array
$newModulesarray Module array to add to $modules

Definition at line 128 of file ApiQuery.php.

Referenced by __construct().

Here is the caller graph for this function:

ApiQuery::doExport ( pageSet,
result 
) [private]
Parameters:
$pageSetApiPageSet Pages to be exported
$resultApiResult Result to output to

Definition at line 481 of file ApiQuery.php.

References $result, $title, getDB(), and ApiResult\setContent().

Referenced by outputGeneralPageInfo().

Here is the call graph for this function:

Here is the caller graph for this function:

Query execution happens in the following steps: #1 Create a PageSet object with any pages requested by the user #2 If using a generator, execute it to get a new ApiPageSet object #3 Instantiate all requested modules.

This way the PageSet object will know what shared data is required, and minimize DB calls. #4 Output all normalization and redirect resolution information #5 Execute all requested modules

Reimplemented from ApiBase.

Definition at line 227 of file ApiQuery.php.

References $params, addCustomFldsToPageSet(), executeGeneratorModule(), ApiBase\extractRequestParams(), ApiBase\getMain(), instantiateModules(), mergeCacheMode(), newGenerator(), outputGeneralPageInfo(), and wfRunHooks().

Here is the call graph for this function:

ApiQuery::executeGeneratorModule ( generator,
modules 
) [protected]

For generator mode, execute generator, and use its output as new ApiPageSet.

Parameters:
$generatorApiQueryGeneratorBase Generator Module
$modulesarray of module objects

Definition at line 549 of file ApiQuery.php.

References addCustomFldsToPageSet(), and wfRunHooks().

Referenced by execute().

Here is the call graph for this function:

Here is the caller graph for this function:

Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (array with PARAM_* constants as keys) Don't call this function directly: use getFinalParams() to allow hooks to modify parameters as needed.

Returns:
array or false

Reimplemented from ApiBase.

Definition at line 571 of file ApiQuery.php.

References ApiBase\PARAM_ISMULTI, and ApiBase\PARAM_TYPE.

If the module may only be used with a certain format module, it should override this method to return an instance of that formatter.

A value of null means the default format will be used.

Returns:
mixed instance of a derived class of ApiFormatBase, or null

Reimplemented from ApiBase.

Definition at line 205 of file ApiQuery.php.

References ApiBase\getMain(), and ApiBase\getParameter().

Here is the call graph for this function:

Gets a default slave database connection object.

Returns:
Database

Reimplemented from ApiBase.

Definition at line 140 of file ApiQuery.php.

References ApiBase\profileDBIn(), ApiBase\profileDBOut(), and wfGetDB().

Referenced by doExport().

Here is the call graph for this function:

Here is the caller graph for this function:

Returns the description string for this module.

Returns:
mixed string or array of strings

Reimplemented from ApiBase.

Definition at line 685 of file ApiQuery.php.

Returns usage examples for this module.

Return false if no examples are available.

Returns:
false|string|array

Reimplemented from ApiBase.

Definition at line 699 of file ApiQuery.php.

Returns:
false|string|array Returns a false if the module has no help url, else returns a (array of) string

Reimplemented from ApiBase.

Definition at line 706 of file ApiQuery.php.

Get the array mapping module names to class names.

Returns:
array array(modulename => classname)

Definition at line 180 of file ApiQuery.php.

ApiQuery::getModuleType ( moduleName)

Get whether the specified module is a prop, list or a meta query module.

Parameters:
$moduleNamestring Name of the module to find type for
Returns:
mixed string or null

Definition at line 189 of file ApiQuery.php.

ApiQuery::getNamedDB ( name,
db,
groups 
)

Get the query database connection with the given name.

If no such connection has been requested before, it will be created. Subsequent calls with the same $name will return the same connection as the first, regardless of the values of $db and $groups

Parameters:
$namestring Name to assign to the database connection
$dbint One of the DB_* constants
$groupsarray Query groups
Returns:
Database

Definition at line 159 of file ApiQuery.php.

References ApiBase\profileDBIn(), ApiBase\profileDBOut(), and wfGetDB().

Here is the call graph for this function:

Gets the set of pages the user has requested (or generated)

Returns:
ApiPageSet

Definition at line 172 of file ApiQuery.php.

Referenced by outputGeneralPageInfo().

Here is the caller graph for this function:

Returns an array of parameter descriptions.

Don't call this functon directly: use getFinalParamDescription() to allow hooks to modify descriptions as needed.

Returns:
array or false

Reimplemented from ApiBase.

Definition at line 668 of file ApiQuery.php.

Returns a list of all possible errors returned by the module.

Returns:
array in the format of array( key, param1, param2, ... ) or array( 'code' => ..., 'info' => ... )

Reimplemented from ApiBase.

Definition at line 693 of file ApiQuery.php.

Returns a string that identifies the version of the extending class.

Typically includes the class name, the svn revision, timestamp, and last author. Usually done with SVN's Id keyword

Returns:
string

Reimplemented from ApiBase.

Definition at line 714 of file ApiQuery.php.

ApiQuery::instantiateModules ( &$  modules,
param,
moduleList 
) [private]

Create instances of all modules requested by the client.

Parameters:
$modulesArray to append instantiated modules to
$paramstring Parameter name to read modules from
$moduleListArray array(modulename => classname)

Definition at line 317 of file ApiQuery.php.

Referenced by execute().

Here is the caller graph for this function:

Override the parent to generate help messages for all available query modules.

Returns:
string

Reimplemented from ApiBase.

Definition at line 601 of file ApiQuery.php.

References makeHelpMsgHelper().

Here is the call graph for this function:

ApiQuery::makeHelpMsgHelper ( moduleList,
paramName 
) [private]

For all modules in $moduleList, generate help messages and join them together.

Parameters:
$moduleListArray array(modulename => classname)
$paramNamestring Parameter name
Returns:
string

Definition at line 631 of file ApiQuery.php.

References ApiMain\makeHelpMsgHeader().

Referenced by __construct(), and makeHelpMsg().

Here is the call graph for this function:

Here is the caller graph for this function:

Override to add extra parameters from PageSet.

Returns:
string

Reimplemented from ApiBase.

Definition at line 659 of file ApiQuery.php.

ApiQuery::mergeCacheMode ( cacheMode,
modCacheMode 
) [protected]

Update a cache mode string, applying the cache mode of a new module to it.

The cache mode may increase in the level of privacy, but public modules added to private data do not decrease the level of privacy.

Parameters:
$cacheModestring
$modCacheModestring
Returns:
string

Definition at line 284 of file ApiQuery.php.

Referenced by execute().

Here is the caller graph for this function:

ApiQuery::newGenerator ( generatorName)

Create a generator object of the given type and return it.

Parameters:
$generatorNamestring Module name
Returns:
ApiQueryGeneratorBase

Definition at line 526 of file ApiQuery.php.

References ApiBase\dieDebug(), and ApiBase\dieUsage().

Referenced by execute().

Here is the call graph for this function:

Here is the caller graph for this function:

Appends an element for each page in the current pageSet with the most general information (id, title), plus any title normalizations and missing or invalid title/pageids/revids.

Definition at line 330 of file ApiQuery.php.

References $result, $title, ApiQueryBase\addTitleInfo(), doExport(), SpecialPageFactory\exists(), getPageSet(), ApiBase\getResult(), Title\newFromText(), wfExpandUrl(), and wfFindFile().

Referenced by execute().

Here is the call graph for this function:

Here is the caller graph for this function:

Indicates if this module needs maxlag to be checked.

Returns:
bool

Reimplemented from ApiBase.

Definition at line 664 of file ApiQuery.php.


Member Data Documentation

ApiQuery::$convertTitles

Definition at line 47 of file ApiQuery.php.

ApiQuery::$iwUrl

Definition at line 47 of file ApiQuery.php.

ApiQuery::$mAllowedGenerators = array() [protected]

Definition at line 104 of file ApiQuery.php.

ApiQuery::$mListModuleNames

Definition at line 40 of file ApiQuery.php.

ApiQuery::$mMetaModuleNames

Definition at line 40 of file ApiQuery.php.

ApiQuery::$mNamedDB = array() [private]

Definition at line 102 of file ApiQuery.php.

ApiQuery::$mPageSet [private]

Definition at line 45 of file ApiQuery.php.

ApiQuery::$mPropModuleNames [private]

Definition at line 40 of file ApiQuery.php.

ApiQuery::$mQueryListModules [private]
Initial value:
 array(
                'allimages' => 'ApiQueryAllimages',
                'allpages' => 'ApiQueryAllpages',
                'alllinks' => 'ApiQueryAllLinks',
                'allcategories' => 'ApiQueryAllCategories',
                'allusers' => 'ApiQueryAllUsers',
                'backlinks' => 'ApiQueryBacklinks',
                'blocks' => 'ApiQueryBlocks',
                'categorymembers' => 'ApiQueryCategoryMembers',
                'deletedrevs' => 'ApiQueryDeletedrevs',
                'embeddedin' => 'ApiQueryBacklinks',
                'filearchive' => 'ApiQueryFilearchive',
                'imageusage' => 'ApiQueryBacklinks',
                'iwbacklinks' => 'ApiQueryIWBacklinks',
                'langbacklinks' => 'ApiQueryLangBacklinks',
                'logevents' => 'ApiQueryLogEvents',
                'recentchanges' => 'ApiQueryRecentChanges',
                'search' => 'ApiQuerySearch',
                'tags' => 'ApiQueryTags',
                'usercontribs' => 'ApiQueryContributions',
                'watchlist' => 'ApiQueryWatchlist',
                'watchlistraw' => 'ApiQueryWatchlistRaw',
                'exturlusage' => 'ApiQueryExtLinksUsage',
                'users' => 'ApiQueryUsers',
                'random' => 'ApiQueryRandom',
                'protectedtitles' => 'ApiQueryProtectedTitles',
                'querypage' => 'ApiQueryQueryPage',
        )

Definition at line 66 of file ApiQuery.php.

ApiQuery::$mQueryMetaModules [private]
Initial value:
 array(
                'siteinfo' => 'ApiQuerySiteinfo',
                'userinfo' => 'ApiQueryUserInfo',
                'allmessages' => 'ApiQueryAllmessages',
        )

Definition at line 95 of file ApiQuery.php.

ApiQuery::$mQueryPropModules [private]
Initial value:
 array(
                'info' => 'ApiQueryInfo',
                'revisions' => 'ApiQueryRevisions',
                'links' => 'ApiQueryLinks',
                'iwlinks' => 'ApiQueryIWLinks',
                'langlinks' => 'ApiQueryLangLinks',
                'images' => 'ApiQueryImages',
                'imageinfo' => 'ApiQueryImageInfo',
                'stashimageinfo' => 'ApiQueryStashImageInfo',
                'templates' => 'ApiQueryLinks',
                'categories' => 'ApiQueryCategories',
                'extlinks' => 'ApiQueryExternalLinks',
                'categoryinfo' => 'ApiQueryCategoryInfo',
                'duplicatefiles' => 'ApiQueryDuplicateFiles',
                'pageprops' => 'ApiQueryPageProps',
        )

Definition at line 49 of file ApiQuery.php.

ApiQuery::$mSlaveDB = null [private]

Definition at line 101 of file ApiQuery.php.

ApiQuery::$params [private]

Definition at line 47 of file ApiQuery.php.

Referenced by execute().

ApiQuery::$redirects

Definition at line 47 of file ApiQuery.php.


The documentation for this class was generated from the following file: