MediaWiki
master
|
This is the main query class. More...
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 () | |
getDB () | |
Gets a default slave database connection object. | |
getDescription () | |
Returns the description string for this module. | |
getExamples () | |
Returns usage examples for this module. | |
getGenerators () | |
Get the generators array mapping module names to class names. | |
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 | |
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() | |
ApiPageSet | $mPageSet |
$mPropModuleNames | |
array | $mQueryGenerators |
List of Api Query generator modules Defined in code, rather than being derived at runtime, due to performance reasons. | |
array | $mQueryListModules |
List of Api Query list modules. | |
array | $mQueryMetaModules |
List of Api Query meta modules. | |
array | $mQueryPropModules |
List of Api Query prop modules. | |
$mSlaveDB = null | |
$params |
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.
ApiQuery::__construct | ( | $ | main, |
$ | action | ||
) |
$main | ApiMain |
$action | string |
Definition at line 149 of file ApiQuery.php.
References appendUserModules(), and global.
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 360 of file ApiQuery.php.
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 170 of file ApiQuery.php.
Referenced by __construct().
ApiQuery::doExport | ( | $ | pageSet, |
$ | result | ||
) | [private] |
$pageSet | ApiPageSet Pages to be exported |
$result | ApiResult Result to output to |
Definition at line 543 of file ApiQuery.php.
References $result, $title, $titles, $user, array(), as, getDB(), ContextSource\getUser(), and ApiResult\setContent().
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 280 of file ApiQuery.php.
ApiQuery::executeGeneratorModule | ( | $ | generator, |
$ | modules | ||
) | [protected] |
For generator mode, execute generator, and use its output as new ApiPageSet.
$generator | ApiQueryGeneratorBase Generator Module |
$modules | array of module objects |
Definition at line 612 of file ApiQuery.php.
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 634 of file ApiQuery.php.
ApiQuery::getDB | ( | ) |
Gets a default slave database connection object.
Reimplemented from ApiBase.
Definition at line 182 of file ApiQuery.php.
References ApiBase\profileDBIn(), ApiBase\profileDBOut(), and wfGetDB().
Referenced by doExport().
Returns the description string for this module.
Reimplemented from ApiBase.
Definition at line 744 of file ApiQuery.php.
Returns usage examples for this module.
Return false if no examples are available.
Reimplemented from ApiBase.
Definition at line 758 of file ApiQuery.php.
Get the generators array mapping module names to class names.
Definition at line 230 of file ApiQuery.php.
Reimplemented from ApiBase.
Definition at line 765 of file ApiQuery.php.
Get the array mapping module names to class names.
Definition at line 222 of file ApiQuery.php.
ApiQuery::getModuleType | ( | $ | moduleName | ) |
Get whether the specified module is a prop, list or a meta query module.
$moduleName | string Name of the module to find type for |
Definition at line 239 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 201 of file ApiQuery.php.
Gets the set of pages the user has requested (or generated)
Definition at line 214 of file ApiQuery.php.
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 727 of file ApiQuery.php.
Returns a list of all possible errors returned by the module.
Reimplemented from ApiBase.
Definition at line 752 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
Reimplemented from ApiBase.
Definition at line 773 of file ApiQuery.php.
ApiQuery::instantiateModules | ( | &$ | modules, |
$ | param, | ||
$ | moduleList | ||
) | [private] |
Create instances of all modules requested by the client.
$modules | Array to append instantiated modules to |
$param | string Parameter name to read modules from |
$moduleList | Array array(modulename => classname) |
Definition at line 376 of file ApiQuery.php.
Override the parent to generate help messages for all available query modules.
Reimplemented from ApiBase.
Definition at line 664 of file ApiQuery.php.
References makeHelpMsgHelper().
ApiQuery::makeHelpMsgHelper | ( | $ | moduleList, |
$ | paramName | ||
) | [private] |
For all modules in $moduleList, generate help messages and join them together.
$moduleList | Array array(modulename => classname) |
$paramName | string Parameter name |
Definition at line 691 of file ApiQuery.php.
Referenced by makeHelpMsg().
Override to add extra parameters from PageSet.
Reimplemented from ApiBase.
Definition at line 718 of file ApiQuery.php.
Referenced by shouldCheckMaxlag().
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.
$cacheMode | string |
$modCacheMode | string |
Definition at line 340 of file ApiQuery.php.
ApiQuery::newGenerator | ( | $ | generatorName | ) |
Create a generator object of the given type and return it.
$generatorName | string Module name |
Definition at line 589 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 389 of file ApiQuery.php.
Indicates if this module needs maxlag to be checked.
Reimplemented from ApiBase.
Definition at line 723 of file ApiQuery.php.
References makeHelpMsgParameters().
ApiQuery::$convertTitles |
Definition at line 46 of file ApiQuery.php.
ApiQuery::$iwUrl |
Definition at line 46 of file ApiQuery.php.
ApiQuery::$mAllowedGenerators [protected] |
Definition at line 143 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 141 of file ApiQuery.php.
ApiPageSet ApiQuery::$mPageSet [private] |
Definition at line 44 of file ApiQuery.php.
ApiQuery::$mPropModuleNames [private] |
Definition at line 40 of file ApiQuery.php.
array ApiQuery::$mQueryGenerators [private] |
array( 'allcategories' => 'ApiQueryAllCategories', 'allimages' => 'ApiQueryAllImages', 'alllinks' => 'ApiQueryAllLinks', 'allpages' => 'ApiQueryAllPages', 'backlinks' => 'ApiQueryBacklinks', 'categories' => 'ApiQueryCategories', 'categorymembers' => 'ApiQueryCategoryMembers', 'duplicatefiles' => 'ApiQueryDuplicateFiles', 'embeddedin' => 'ApiQueryBacklinks', 'exturlusage' => 'ApiQueryExtLinksUsage', 'images' => 'ApiQueryImages', 'imageusage' => 'ApiQueryBacklinks', 'iwbacklinks' => 'ApiQueryIWBacklinks', 'langbacklinks' => 'ApiQueryLangBacklinks', 'links' => 'ApiQueryLinks', 'protectedtitles' => 'ApiQueryProtectedTitles', 'querypage' => 'ApiQueryQueryPage', 'random' => 'ApiQueryRandom', 'recentchanges' => 'ApiQueryRecentChanges', 'search' => 'ApiQuerySearch', 'templates' => 'ApiQueryLinks', 'watchlist' => 'ApiQueryWatchlist', 'watchlistraw' => 'ApiQueryWatchlistRaw', )
List of Api Query generator modules Defined in code, rather than being derived at runtime, due to performance reasons.
Definition at line 114 of file ApiQuery.php.
array ApiQuery::$mQueryListModules [private] |
array( 'allcategories' => 'ApiQueryAllCategories', 'allimages' => 'ApiQueryAllImages', 'alllinks' => 'ApiQueryAllLinks', 'allpages' => 'ApiQueryAllPages', 'allusers' => 'ApiQueryAllUsers', 'backlinks' => 'ApiQueryBacklinks', 'blocks' => 'ApiQueryBlocks', 'categorymembers' => 'ApiQueryCategoryMembers', 'deletedrevs' => 'ApiQueryDeletedrevs', 'embeddedin' => 'ApiQueryBacklinks', 'exturlusage' => 'ApiQueryExtLinksUsage', 'filearchive' => 'ApiQueryFilearchive', 'imageusage' => 'ApiQueryBacklinks', 'iwbacklinks' => 'ApiQueryIWBacklinks', 'langbacklinks' => 'ApiQueryLangBacklinks', 'logevents' => 'ApiQueryLogEvents', 'protectedtitles' => 'ApiQueryProtectedTitles', 'querypage' => 'ApiQueryQueryPage', 'random' => 'ApiQueryRandom', 'recentchanges' => 'ApiQueryRecentChanges', 'search' => 'ApiQuerySearch', 'tags' => 'ApiQueryTags', 'usercontribs' => 'ApiQueryContributions', 'users' => 'ApiQueryUsers', 'watchlist' => 'ApiQueryWatchlist', 'watchlistraw' => 'ApiQueryWatchlistRaw', )
List of Api Query list modules.
Definition at line 71 of file ApiQuery.php.
array ApiQuery::$mQueryMetaModules [private] |
array( 'allmessages' => 'ApiQueryAllMessages', 'siteinfo' => 'ApiQuerySiteinfo', 'userinfo' => 'ApiQueryUserInfo', )
List of Api Query meta modules.
Definition at line 103 of file ApiQuery.php.
array ApiQuery::$mQueryPropModules [private] |
array( 'categories' => 'ApiQueryCategories', 'categoryinfo' => 'ApiQueryCategoryInfo', 'duplicatefiles' => 'ApiQueryDuplicateFiles', 'extlinks' => 'ApiQueryExternalLinks', 'images' => 'ApiQueryImages', 'imageinfo' => 'ApiQueryImageInfo', 'info' => 'ApiQueryInfo', 'links' => 'ApiQueryLinks', 'iwlinks' => 'ApiQueryIWLinks', 'langlinks' => 'ApiQueryLangLinks', 'pageprops' => 'ApiQueryPageProps', 'revisions' => 'ApiQueryRevisions', 'stashimageinfo' => 'ApiQueryStashImageInfo', 'templates' => 'ApiQueryLinks', )
List of Api Query prop modules.
Definition at line 51 of file ApiQuery.php.
ApiQuery::$mSlaveDB = null [private] |
Definition at line 140 of file ApiQuery.php.
ApiQuery::$params [private] |
Definition at line 46 of file ApiQuery.php.
ApiQuery::$redirects |
Definition at line 46 of file ApiQuery.php.