MediaWiki
REL1_19
|
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 () | |
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 |
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 | ||
) |
Definition at line 106 of file ApiQuery.php.
References $wgAPIListModules, $wgAPIMetaModules, $wgAPIPropModules, appendUserModules(), and makeHelpMsgHelper().
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 304 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 128 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 481 of file ApiQuery.php.
References $result, $title, getDB(), and ApiResult\setContent().
Referenced by outputGeneralPageInfo().
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().
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 549 of file ApiQuery.php.
References addCustomFldsToPageSet(), and wfRunHooks().
Referenced by execute().
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 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.
Reimplemented from ApiBase.
Definition at line 205 of file ApiQuery.php.
References ApiBase\getMain(), and ApiBase\getParameter().
ApiQuery::getDB | ( | ) |
Gets a default slave database connection object.
Reimplemented from ApiBase.
Definition at line 140 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 685 of file ApiQuery.php.
Returns usage examples for this module.
Return false if no examples are available.
Reimplemented from ApiBase.
Definition at line 699 of file ApiQuery.php.
Reimplemented from ApiBase.
Definition at line 706 of file ApiQuery.php.
Get the array mapping module names to class names.
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.
$moduleName | string Name of the module to find type for |
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
$name | string Name to assign to the database connection |
$db | int One of the DB_* constants |
$groups | array Query groups |
Definition at line 159 of file ApiQuery.php.
References ApiBase\profileDBIn(), ApiBase\profileDBOut(), and wfGetDB().
Gets the set of pages the user has requested (or generated)
Definition at line 172 of file ApiQuery.php.
Referenced by outputGeneralPageInfo().
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 668 of file ApiQuery.php.
Returns a list of all possible errors returned by the module.
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
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.
$modules | Array to append instantiated modules to |
$param | string Parameter name to read modules from |
$moduleList | Array array(modulename => classname) |
Definition at line 317 of file ApiQuery.php.
Referenced by execute().
Override the parent to generate help messages for all available query modules.
Reimplemented from ApiBase.
Definition at line 601 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 631 of file ApiQuery.php.
References ApiMain\makeHelpMsgHeader().
Referenced by __construct(), and makeHelpMsg().
Override to add extra parameters from PageSet.
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.
$cacheMode | string |
$modCacheMode | string |
Definition at line 284 of file ApiQuery.php.
Referenced by execute().
ApiQuery::newGenerator | ( | $ | generatorName | ) |
Create a generator object of the given type and return it.
$generatorName | string Module name |
Definition at line 526 of file ApiQuery.php.
References ApiBase\dieDebug(), and ApiBase\dieUsage().
Referenced by execute().
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 330 of file ApiQuery.php.
References $result, $title, ApiQueryBase\addTitleInfo(), doExport(), SpecialPageFactory\exists(), getPageSet(), ApiBase\getResult(), Title\newFromText(), wfExpandUrl(), and wfFindFile().
Referenced by execute().
Indicates if this module needs maxlag to be checked.
Reimplemented from ApiBase.
Definition at line 664 of file ApiQuery.php.
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] |
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] |
array( 'siteinfo' => 'ApiQuerySiteinfo', 'userinfo' => 'ApiQueryUserInfo', 'allmessages' => 'ApiQueryAllmessages', )
Definition at line 95 of file ApiQuery.php.
ApiQuery::$mQueryPropModules [private] |
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.