Inherits ApiBase.
Public Member Functions | |
__construct ($main, $action) | |
getDB () | |
Gets a default slave database connection object. | |
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). | |
getModules () | |
Get the array mapping module names to class names. | |
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. | |
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. | |
makeHelpMsg () | |
Override the parent to generate help messages for all available query modules. | |
makeHelpMsgParameters () | |
Override to add extra parameters from PageSet. | |
shouldCheckMaxlag () | |
Indicates if this module needs maxlag to be checked. | |
getParamDescription () | |
Returns an array of parameter descriptions. | |
getDescription () | |
Returns the description string for this module. | |
getVersion () | |
Returns a string that identifies the version of the extending class. | |
Protected Member Functions | |
executeGeneratorModule ($generatorName, $modules) | |
For generator mode, execute generator, and use its output as new ApiPageSet. | |
getExamples () | |
Returns usage examples for this module. | |
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. | |
InstantiateModules (&$modules, $param, $moduleList) | |
Create instances of all modules requested by the client. | |
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. | |
makeHelpMsgHelper ($moduleList, $paramName) | |
For all modules in $moduleList, generate help messages and join them together. | |
Static Private Member Functions | |
static | appendUserModules (&$modules, $newModules) |
Helper function to append any add-in modules to the list. | |
Private Attributes | |
$mPropModuleNames | |
$mListModuleNames | |
$mMetaModuleNames | |
$mPageSet | |
$params | |
$redirect | |
$mQueryPropModules | |
$mQueryListModules | |
$mQueryMetaModules | |
$mSlaveDB = null | |
$mNamedDB = array() |
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 42 of file ApiQuery.php.
ApiQuery::__construct | ( | $ | main, | |
$ | action | |||
) |
Definition at line 95 of file ApiQuery.php.
References $action, $wgAPIListModules, $wgAPIMetaModules, $wgAPIPropModules, and appendUserModules().
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.
$modules | array of module objects | |
$pageSet | ApiPageSet |
Definition at line 246 of file ApiQuery.php.
Referenced by execute(), and executeGeneratorModule().
static ApiQuery::appendUserModules | ( | &$ | modules, | |
$ | newModules | |||
) | [static, private] |
Helper function to append any add-in modules to the list.
$modules | array Module array | |
$newModules | array Module array to add to $modules |
Definition at line 118 of file ApiQuery.php.
Referenced by __construct().
ApiQuery::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.
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 194 of file ApiQuery.php.
References addCustomFldsToPageSet(), executeGeneratorModule(), ApiBase::extractRequestParams(), InstantiateModules(), outputGeneralPageInfo(), and wfRunHooks().
ApiQuery::executeGeneratorModule | ( | $ | generatorName, | |
$ | modules | |||
) | [protected] |
For generator mode, execute generator, and use its output as new ApiPageSet.
$generatorName | string Module name | |
$modules | array of module objects |
Definition at line 417 of file ApiQuery.php.
References addCustomFldsToPageSet(), ApiBase::dieDebug(), ApiBase::dieUsage(), and wfRunHooks().
Referenced by execute().
ApiQuery::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.
Reimplemented from ApiBase.
Definition at line 456 of file ApiQuery.php.
References ApiBase::PARAM_ISMULTI, and ApiBase::PARAM_TYPE.
ApiQuery::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.
A value of null means the default format will be used.
Reimplemented from ApiBase.
Definition at line 174 of file ApiQuery.php.
References ApiBase::getMain(), and ApiBase::getParameter().
ApiQuery::getDB | ( | ) |
Gets a default slave database connection object.
Definition at line 130 of file ApiQuery.php.
References ApiBase::profileDBIn(), ApiBase::profileDBOut(), and wfGetDB().
Referenced by outputGeneralPageInfo().
ApiQuery::getDescription | ( | ) |
Returns the description string for this module.
Reimplemented from ApiBase.
Definition at line 565 of file ApiQuery.php.
ApiQuery::getExamples | ( | ) | [protected] |
Returns usage examples for this module.
Return null if no examples are available.
Reimplemented from ApiBase.
Definition at line 573 of file ApiQuery.php.
ApiQuery::getModules | ( | ) |
Get the array mapping module names to class names.
Definition at line 170 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
$name | string Name to assign to the database connection | |
$db | int One of the DB_* constants | |
$groups | array Query groups |
Definition at line 149 of file ApiQuery.php.
References $db, $name, ApiBase::profileDBIn(), ApiBase::profileDBOut(), and wfGetDB().
ApiQuery::getPageSet | ( | ) |
Gets the set of pages the user has requested (or generated).
Definition at line 162 of file ApiQuery.php.
Referenced by outputGeneralPageInfo().
ApiQuery::getParamDescription | ( | ) |
Returns an array of parameter descriptions.
Don't call this functon directly: use getFinalParamDescription() to allow hooks to modify descriptions as needed.
Reimplemented from ApiBase.
Definition at line 551 of file ApiQuery.php.
ApiQuery::getVersion | ( | ) |
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
Reimplemented from ApiBase.
Definition at line 580 of file ApiQuery.php.
ApiQuery::InstantiateModules | ( | &$ | modules, | |
$ | param, | |||
$ | moduleList | |||
) | [private] |
Create instances of all modules requested by the client.
$modules | array to append instatiated modules to | |
$param | string Parameter name to read modules from | |
$moduleList | array(modulename => classname) |
Definition at line 259 of file ApiQuery.php.
Referenced by execute().
ApiQuery::makeHelpMsg | ( | ) |
Override the parent to generate help messages for all available query modules.
Reimplemented from ApiBase.
Definition at line 484 of file ApiQuery.php.
References $msg, and makeHelpMsgHelper().
ApiQuery::makeHelpMsgHelper | ( | $ | moduleList, | |
$ | paramName | |||
) | [private] |
For all modules in $moduleList, generate help messages and join them together.
$moduleList | array(modulename => classname) | |
$paramName | string Parameter name |
Definition at line 517 of file ApiQuery.php.
References $msg, and ApiMain::makeHelpMsgHeader().
Referenced by makeHelpMsg().
ApiQuery::makeHelpMsgParameters | ( | ) |
Override to add extra parameters from PageSet.
Reimplemented from ApiBase.
Definition at line 542 of file ApiQuery.php.
ApiQuery::outputGeneralPageInfo | ( | ) | [private] |
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 271 of file ApiQuery.php.
References $result, $title, ApiQueryBase::addTitleInfo(), getDB(), getPageSet(), ApiBase::getResult(), and ApiResult::setContent().
Referenced by execute().
ApiQuery::shouldCheckMaxlag | ( | ) |
Indicates if this module needs maxlag to be checked.
Reimplemented from ApiBase.
Definition at line 547 of file ApiQuery.php.
ApiQuery::$mListModuleNames [private] |
Definition at line 44 of file ApiQuery.php.
ApiQuery::$mMetaModuleNames [private] |
Definition at line 44 of file ApiQuery.php.
ApiQuery::$mNamedDB = array() [private] |
Definition at line 93 of file ApiQuery.php.
ApiQuery::$mPageSet [private] |
Definition at line 45 of file ApiQuery.php.
ApiQuery::$mPropModuleNames [private] |
Definition at line 44 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', 'imageusage' => 'ApiQueryBacklinks', 'logevents' => 'ApiQueryLogEvents', 'recentchanges' => 'ApiQueryRecentChanges', 'search' => 'ApiQuerySearch', 'usercontribs' => 'ApiQueryContributions', 'watchlist' => 'ApiQueryWatchlist', 'watchlistraw' => 'ApiQueryWatchlistRaw', 'exturlusage' => 'ApiQueryExtLinksUsage', 'users' => 'ApiQueryUsers', 'random' => 'ApiQueryRandom', 'protectedtitles' => 'ApiQueryProtectedTitles', )
Definition at line 62 of file ApiQuery.php.
ApiQuery::$mQueryMetaModules [private] |
Initial value:
array ( 'siteinfo' => 'ApiQuerySiteinfo', 'userinfo' => 'ApiQueryUserInfo', 'allmessages' => 'ApiQueryAllmessages', )
Definition at line 86 of file ApiQuery.php.
ApiQuery::$mQueryPropModules [private] |
Initial value:
array ( 'info' => 'ApiQueryInfo', 'revisions' => 'ApiQueryRevisions', 'links' => 'ApiQueryLinks', 'langlinks' => 'ApiQueryLangLinks', 'images' => 'ApiQueryImages', 'imageinfo' => 'ApiQueryImageInfo', 'templates' => 'ApiQueryLinks', 'categories' => 'ApiQueryCategories', 'extlinks' => 'ApiQueryExternalLinks', 'categoryinfo' => 'ApiQueryCategoryInfo', 'duplicatefiles' => 'ApiQueryDuplicateFiles', )
Definition at line 48 of file ApiQuery.php.
ApiQuery::$mSlaveDB = null [private] |
Definition at line 92 of file ApiQuery.php.
ApiQuery::$params [private] |
Definition at line 46 of file ApiQuery.php.
ApiQuery::$redirect [private] |
Definition at line 46 of file ApiQuery.php.