MediaWiki  REL1_20
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 ()
 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.
 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.
 makeGeneratorList ($moduleList)
 Adds any classes that are a subclass of ApiQueryGeneratorBase to the allowed generator list.
 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
 $mQueryListModules
 $mQueryMetaModules
 $mQueryPropModules
 $mSlaveDB = null
 $params

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


Member Function Documentation

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.

Parameters:
$modulesarray of module objects
$pageSetApiPageSet

Definition at line 328 of file ApiQuery.php.

static ApiQuery::appendUserModules ( &$  modules,
newModules 
) [static, private]

Helper function to append any add-in modules to the list.

Parameters:
$modulesarray Module array
$newModulesarray Module array to add to $modules

Definition at line 146 of file ApiQuery.php.

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

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

ApiQuery::executeGeneratorModule ( generator,
modules 
) [protected]

For generator mode, execute generator, and use its output as new ApiPageSet.

Parameters:
$generatorApiQueryGeneratorBase Generator Module
$modulesarray of module objects

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

Returns:
array|bool

Reimplemented from ApiBase.

Definition at line 601 of file ApiQuery.php.

References ApiBase\PARAM_ISMULTI, and ApiBase\PARAM_TYPE.

Returns:
ApiFormatRaw|null

Reimplemented from ApiBase.

Definition at line 226 of file ApiQuery.php.

Gets a default slave database connection object.

Returns:
DatabaseBase

Reimplemented from ApiBase.

Definition at line 158 of file ApiQuery.php.

Returns the description string for this module.

Returns:
mixed string or array of strings

Reimplemented from ApiBase.

Definition at line 724 of file ApiQuery.php.

Returns usage examples for this module.

Return false if no examples are available.

Returns:
bool|string|array

Reimplemented from ApiBase.

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

Get the array mapping module names to class names.

Returns:
array array(modulename => classname)

Definition at line 198 of file ApiQuery.php.

ApiQuery::getModuleType ( moduleName)

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

Parameters:
$moduleNamestring Name of the module to find type for
Returns:
mixed string or null

Definition at line 207 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:
$namestring Name to assign to the database connection
$dbint One of the DB_* constants
$groupsarray Query groups
Returns:
DatabaseBase

Definition at line 177 of file ApiQuery.php.

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

Returns:
ApiPageSet

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

Returns:
array|bool False on no parameter descriptions

Reimplemented from ApiBase.

Definition at line 707 of file ApiQuery.php.

References LanguageConverter\$languagesWithVariants.

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

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

Reimplemented from ApiBase.

Definition at line 732 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

Returns:
string

Reimplemented from ApiBase.

Definition at line 753 of file ApiQuery.php.

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

Create instances of all modules requested by the client.

Parameters:
$modulesArray to append instantiated modules to
$paramstring Parameter name to read modules from
$moduleListArray array(modulename => classname)

Definition at line 344 of file ApiQuery.php.

ApiQuery::makeGeneratorList ( moduleList) [private]

Adds any classes that are a subclass of ApiQueryGeneratorBase to the allowed generator list.

Parameters:
$moduleListarray()

Definition at line 686 of file ApiQuery.php.

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

Returns:
string

Reimplemented from ApiBase.

Definition at line 631 of file ApiQuery.php.

ApiQuery::makeHelpMsgHelper ( moduleList,
paramName 
) [private]

For all modules in $moduleList, generate help messages and join them together.

Parameters:
$moduleListArray array(modulename => classname)
$paramNamestring Parameter name
Returns:
string

Definition at line 658 of file ApiQuery.php.

Override to add extra parameters from PageSet.

Returns:
string

Reimplemented from ApiBase.

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

ApiQuery::newGenerator ( generatorName)

Create a generator object of the given type and return it.

Parameters:
$generatorNamestring Module name
Returns:
ApiQueryGeneratorBase

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

Indicates if this module needs maxlag to be checked.

Returns:
bool

Reimplemented from ApiBase.

Definition at line 703 of file ApiQuery.php.


Member Data Documentation

ApiQuery::$convertTitles

Definition at line 46 of file ApiQuery.php.

ApiQuery::$iwUrl

Definition at line 46 of file ApiQuery.php.

ApiQuery::$mAllowedGenerators = array() [protected]

Definition at line 103 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 101 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.

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

Definition at line 65 of file ApiQuery.php.

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

Definition at line 94 of file ApiQuery.php.

ApiQuery::$mQueryPropModules [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 48 of file ApiQuery.php.

ApiQuery::$mSlaveDB = null [private]

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


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