MediaWiki  REL1_22
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 ($flags=0)
 getCustomPrinter ()
 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 ()
 getModuleManager ()
 Overrides to return this instance's module manager.
 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.
 makeHelpMsg ()
 Override the parent to generate help messages for all available query modules.
 setGeneratorContinue ($module, $paramName, $paramValue)
 This method is called by the generator base when generator in the smart-continue mode tries to set 'query-continue' value.
 shouldCheckMaxlag ()
 Indicates if this module needs maxlag to be checked.

Protected Member Functions

 mergeCacheMode ($cacheMode, $modCacheMode)
 Update a cache mode string, applying the cache mode of a new module to it.

Private Member Functions

 doExport ($pageSet, $result)
 initContinue (&$pagesetParams, &$completeModules)
 Parse 'continue' parameter into the list of complete modules and a list of generator parameters.
 initModules ($allModules, $completeModules, $usePageset)
 Validate sub-modules, filter out completed ones, and do requestExtraData()
 instantiateModules (&$modules, $param)
 Create instances of all modules requested by the client.
 makeHelpMsgHelper ($group)
 For all modules of a given group, 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.

Private Attributes

 $mGeneratorContinue
 $mModuleMgr
 $mNamedDB = array()
ApiPageSet $mPageSet
 $mParams
 $mUseLegacyContinue

Static Private Attributes

static $QueryListModules
static $QueryMetaModules
static $QueryPropModules

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 
)
Parameters:
$mainApiMain
$actionstring

Definition at line 123 of file ApiQuery.php.


Member Function Documentation

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

Definition at line 575 of file ApiQuery.php.

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 237 of file ApiQuery.php.

ApiQuery::getAllowedParams ( flags = 0)

Definition at line 617 of file ApiQuery.php.

References $flags, $result, array(), getPageSet(), ApiBase\PARAM_ISMULTI, and ApiBase\PARAM_TYPE.

Returns:
ApiFormatRaw|null

Reimplemented from ApiBase.

Definition at line 215 of file ApiQuery.php.

Returns the description string for this module.

Returns:
mixed string or array of strings

Reimplemented from ApiBase.

Definition at line 715 of file ApiQuery.php.

References array().

Returns usage examples for this module.

Return false if no examples are available.

Returns:
bool|string|array

Reimplemented from ApiBase.

Definition at line 730 of file ApiQuery.php.

References array().

Get the generators array mapping module names to class names.

Deprecated:
since 1.21, list of generators is maintained by ApiPageSet
Returns:
array array(modulename => classname)

Definition at line 191 of file ApiQuery.php.

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

Reimplemented from ApiBase.

Definition at line 737 of file ApiQuery.php.

References array().

Overrides to return this instance's module manager.

Returns:
ApiModuleManager

Reimplemented from ApiBase.

Definition at line 145 of file ApiQuery.php.

Get the array mapping module names to class names.

Deprecated:
since 1.21, use getModuleManager()'s methods instead
Returns:
array array(modulename => classname)

Definition at line 181 of file ApiQuery.php.

ApiQuery::getModuleType ( moduleName)

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

Deprecated:
since 1.21, use getModuleManager()->getModuleGroup()
Parameters:
string$moduleNameName of the module to find type for
Returns:
mixed string or null

Definition at line 208 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:
string$nameName to assign to the database connection
int$dbOne of the DB_* constants
array$groupsQuery groups
Returns:
DatabaseBase

Definition at line 159 of file ApiQuery.php.

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

Returns:
ApiPageSet

Definition at line 172 of file ApiQuery.php.

Referenced by getAllowedParams(), getParamDescription(), and getPossibleErrors().

Returns an array of parameter descriptions.

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

Returns:
array|bool False on no parameter descriptions

Reimplemented from ApiBase.

Definition at line 699 of file ApiQuery.php.

References array(), and getPageSet().

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

Don't call this function directly: use getFinalPossibleErrors() to allow hooks to modify parameters as needed.

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

Reimplemented from ApiBase.

Definition at line 723 of file ApiQuery.php.

References ApiBase\getFinalPossibleErrors(), and getPageSet().

ApiQuery::initContinue ( &$  pagesetParams,
&$  completeModules 
) [private]

Parse 'continue' parameter into the list of complete modules and a list of generator parameters.

Parameters:
array | null$pagesetParamsreturns list of generator params or null if pageset is done
array | null$completeModulesreturns list of finished modules (as keys), or null if legacy

Definition at line 346 of file ApiQuery.php.

ApiQuery::initModules ( allModules,
completeModules,
usePageset 
) [private]

Validate sub-modules, filter out completed ones, and do requestExtraData()

Parameters:
array$allModulesAn dict of name=>instance of all modules requested by the client
array | null$completeModuleslist of finished modules, or null if legacy continue
bool$usePagesetTrue if pageset will be executed
Returns:
array of modules to be processed during this execution

Definition at line 382 of file ApiQuery.php.

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

Create instances of all modules requested by the client.

Parameters:
array$modulesto append instantiated modules to
string$paramParameter name to read modules from

Definition at line 439 of file ApiQuery.php.

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

Returns:
string

Reimplemented from ApiBase.

Definition at line 647 of file ApiQuery.php.

ApiQuery::makeHelpMsgHelper ( group) [private]

For all modules of a given group, generate help messages and join them together.

Parameters:
string$groupModule group
Returns:
string

Definition at line 670 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 421 of file ApiQuery.php.

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 459 of file ApiQuery.php.

ApiQuery::setGeneratorContinue ( module,
paramName,
paramValue 
)

This method is called by the generator base when generator in the smart-continue mode tries to set 'query-continue' value.

ApiQuery stores those values separately until the post-processing when it is known if the generation should continue or repeat.

Parameters:
ApiQueryGeneratorBase$modulegenerator module
string$paramName
mixed$paramValue
Returns:
bool true if processed, false if this is a legacy continue

Definition at line 559 of file ApiQuery.php.

Indicates if this module needs maxlag to be checked.

Returns:
bool

Reimplemented from ApiBase.

Definition at line 695 of file ApiQuery.php.


Member Data Documentation

ApiQuery::$mGeneratorContinue [private]

Definition at line 116 of file ApiQuery.php.

ApiQuery::$mModuleMgr [private]

Definition at line 115 of file ApiQuery.php.

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

Definition at line 114 of file ApiQuery.php.

ApiPageSet ApiQuery::$mPageSet [private]

Definition at line 111 of file ApiQuery.php.

ApiQuery::$mParams [private]

Definition at line 113 of file ApiQuery.php.

ApiQuery::$mUseLegacyContinue [private]

Definition at line 117 of file ApiQuery.php.

ApiQuery::$QueryListModules [static, private]

Definition at line 65 of file ApiQuery.php.

ApiQuery::$QueryMetaModules [static, private]
Initial value:
 array(
        'allmessages' => 'ApiQueryAllMessages',
        'siteinfo' => 'ApiQuerySiteinfo',
        'userinfo' => 'ApiQueryUserInfo',
        'filerepoinfo' => 'ApiQueryFileRepoInfo',
    )

Definition at line 102 of file ApiQuery.php.

ApiQuery::$QueryPropModules [static, private]
Initial value:
 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',
    )

Definition at line 44 of file ApiQuery.php.


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