MediaWiki  REL1_24
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 (ApiMain $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.
 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)
 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

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

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 ( ApiMain main,
action 
)
Parameters:
ApiMain$main
string$action

Definition at line 129 of file ApiQuery.php.


Member Function Documentation

ApiQuery::doExport ( pageSet,
result 
) [private]
Parameters:
ApiPageSet$pageSetPages to be exported
ApiResult$resultResult to output to

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

ApiQuery::getAllowedParams ( flags = 0)

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

Returns the description string for this module.

Returns:
string|array

Reimplemented from ApiBase.

Definition at line 619 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 629 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 199 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 637 of file ApiQuery.php.

References array().

Overrides to return this instance's module manager.

Returns:
ApiModuleManager

Reimplemented from ApiBase.

Definition at line 151 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 188 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:
string|null

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

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

Returns:
ApiPageSet

Definition at line 179 of file ApiQuery.php.

Referenced by getAllowedParams(), and getParamDescription().

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

References array(), and getPageSet().

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

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

Returns:
string

Reimplemented from ApiBase.

Definition at line 544 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 567 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:
string$cacheMode
string$modCacheMode
Returns:
string

Definition at line 307 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 350 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.

Deprecated:
since 1.24
Parameters:
ApiQueryGeneratorBase$moduleGenerator module
string$paramName
mixed$paramValue
Returns:
bool True if processed, false if this is a legacy continue

Definition at line 462 of file ApiQuery.php.

Indicates if this module needs maxlag to be checked.

Returns:
bool

Reimplemented from ApiBase.

Definition at line 592 of file ApiQuery.php.


Member Data Documentation

ApiQuery::$mModuleMgr [private]

Definition at line 123 of file ApiQuery.php.

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

Definition at line 122 of file ApiQuery.php.

ApiPageSet ApiQuery::$mPageSet [private]

Definition at line 119 of file ApiQuery.php.

ApiQuery::$mParams [private]

Definition at line 121 of file ApiQuery.php.

ApiQuery::$QueryListModules [static, private]

Definition at line 70 of file ApiQuery.php.

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

Definition at line 109 of file ApiQuery.php.

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

Definition at line 44 of file ApiQuery.php.


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