ApiQuery Class Reference
[API]

This is the main query class. More...

Inherits ApiBase.

List of all members.

Public Member Functions

 __construct ($main, $action)
 getDB ()
 Gets a default slave database connection object.
 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).
 getModules ()
 Get the array mapping module names to class names.
 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.
 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.
 newGenerator ($generatorName)
 Create a generator object of the given type and return it.
 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.
 makeHelpMsg ()
 Override the parent to generate help messages for all available query modules.
 makeHelpMsgParameters ()
 Override to add extra parameters from PageSet.
 shouldCheckMaxlag ()
 Indicates if this module needs maxlag to be checked.
 getParamDescription ()
 Returns an array of parameter descriptions.
 getDescription ()
 Returns the description string for this module.
 getPossibleErrors ()
 Returns a list of all possible errors returned by the module.
 getVersion ()
 Returns a string that identifies the version of the extending class.

Protected Member Functions

 mergeCacheMode ($cacheMode, $modCacheMode)
 Update a cache mode string, applying the cache mode of a new module to it.
 executeGeneratorModule ($generator, $modules)
 For generator mode, execute generator, and use its output as new ApiPageSet.
 getExamples ()
 Returns usage examples for this module.

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.
 InstantiateModules (&$modules, $param, $moduleList)
 Create instances of all modules requested by the client.
 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.
 makeHelpMsgHelper ($moduleList, $paramName)
 For all modules in $moduleList, generate help messages and join them together.

Static Private Member Functions

static appendUserModules (&$modules, $newModules)
 Helper function to append any add-in modules to the list.

Private Attributes

 $mPropModuleNames
 $mListModuleNames
 $mMetaModuleNames
 $mPageSet
 $params
 $redirect
 $mQueryPropModules
 $mQueryListModules
 $mQueryMetaModules
 $mSlaveDB = null
 $mNamedDB = array()


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


Constructor & Destructor Documentation

ApiQuery::__construct ( main,
action 
)


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:
$modules array of module objects
$pageSet ApiPageSet

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

Parameters:
$modules array Module array
$newModules array Module array to add to $modules

Definition at line 119 of file ApiQuery.php.

Referenced by __construct().

ApiQuery::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.

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 195 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.

Parameters:
$generatorName string Module name
$modules array of module objects

Definition at line 464 of file ApiQuery.php.

References addCustomFldsToPageSet(), and wfRunHooks().

Referenced by execute().

ApiQuery::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.

Returns:
array

Reimplemented from ApiBase.

Definition at line 486 of file ApiQuery.php.

References ApiBase::PARAM_ISMULTI, and ApiBase::PARAM_TYPE.

ApiQuery::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.

A value of null means the default format will be used.

Returns:
mixed instance of a derived class of ApiFormatBase, or null

Reimplemented from ApiBase.

Definition at line 175 of file ApiQuery.php.

References ApiBase::getMain(), and ApiBase::getParameter().

ApiQuery::getDB (  ) 

Gets a default slave database connection object.

Returns:
Database

Definition at line 131 of file ApiQuery.php.

References ApiBase::profileDBIn(), ApiBase::profileDBOut(), and wfGetDB().

Referenced by outputGeneralPageInfo().

ApiQuery::getDescription (  ) 

Returns the description string for this module.

Returns:
mixed string or array of strings

Reimplemented from ApiBase.

Definition at line 595 of file ApiQuery.php.

ApiQuery::getExamples (  )  [protected]

Returns usage examples for this module.

Return null if no examples are available.

Returns:
mixed string or array of strings

Reimplemented from ApiBase.

Definition at line 609 of file ApiQuery.php.

ApiQuery::getModules (  ) 

Get the array mapping module names to class names.

Returns:
array(modulename => classname)

Definition at line 171 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:
$name string Name to assign to the database connection
$db int One of the DB_* constants
$groups array Query groups
Returns:
Database

Definition at line 150 of file ApiQuery.php.

References $name, ApiBase::profileDBIn(), ApiBase::profileDBOut(), and wfGetDB().

ApiQuery::getPageSet (  ) 

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

Returns:
ApiPageSet

Definition at line 163 of file ApiQuery.php.

Referenced by outputGeneralPageInfo().

ApiQuery::getParamDescription (  ) 

Returns an array of parameter descriptions.

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

Returns:
array

Reimplemented from ApiBase.

Definition at line 581 of file ApiQuery.php.

ApiQuery::getPossibleErrors (  ) 

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

ApiQuery::getVersion (  ) 

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

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

Create instances of all modules requested by the client.

Parameters:
$modules array to append instatiated modules to
$param string Parameter name to read modules from
$moduleList array(modulename => classname)

Definition at line 280 of file ApiQuery.php.

Referenced by execute().

ApiQuery::makeHelpMsg (  ) 

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

Returns:
string

Reimplemented from ApiBase.

Definition at line 514 of file ApiQuery.php.

References $msg, and makeHelpMsgHelper().

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

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

Parameters:
$moduleList array(modulename => classname)
$paramName string Parameter name
Returns:
string

Definition at line 547 of file ApiQuery.php.

References $msg, and ApiMain::makeHelpMsgHeader().

Referenced by makeHelpMsg().

ApiQuery::makeHelpMsgParameters (  ) 

Override to add extra parameters from PageSet.

Returns:
string

Reimplemented from ApiBase.

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

Definition at line 247 of file ApiQuery.php.

Referenced by execute().

ApiQuery::newGenerator ( generatorName  ) 

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

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

References $result, $title, ApiQueryBase::addTitleInfo(), getDB(), getPageSet(), ApiBase::getResult(), and ApiResult::setContent().

Referenced by execute().

ApiQuery::shouldCheckMaxlag (  ) 

Indicates if this module needs maxlag to be checked.

Returns:
bool

Reimplemented from ApiBase.

Definition at line 577 of file ApiQuery.php.


Member Data Documentation

ApiQuery::$mListModuleNames [private]

Definition at line 44 of file ApiQuery.php.

ApiQuery::$mMetaModuleNames [private]

Definition at line 44 of file ApiQuery.php.

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

Definition at line 94 of file ApiQuery.php.

ApiQuery::$mPageSet [private]

Definition at line 45 of file ApiQuery.php.

ApiQuery::$mPropModuleNames [private]

Definition at line 44 of file ApiQuery.php.

ApiQuery::$mQueryListModules [private]

Initial value:

 array (
                'allimages' => 'ApiQueryAllimages',
                'allpages' => 'ApiQueryAllpages',
                'alllinks' => 'ApiQueryAllLinks',
                'allcategories' => 'ApiQueryAllCategories',
                'allusers' => 'ApiQueryAllUsers',
                'backlinks' => 'ApiQueryBacklinks',
                'blocks' => 'ApiQueryBlocks',
                'categorymembers' => 'ApiQueryCategoryMembers',
                'deletedrevs' => 'ApiQueryDeletedrevs',
                'embeddedin' => 'ApiQueryBacklinks',
                'imageusage' => 'ApiQueryBacklinks',
                'logevents' => 'ApiQueryLogEvents',
                'recentchanges' => 'ApiQueryRecentChanges',
                'search' => 'ApiQuerySearch',
                'tags' => 'ApiQueryTags',
                'usercontribs' => 'ApiQueryContributions',
                'watchlist' => 'ApiQueryWatchlist',
                'watchlistraw' => 'ApiQueryWatchlistRaw',
                'exturlusage' => 'ApiQueryExtLinksUsage',
                'users' => 'ApiQueryUsers',
                'random' => 'ApiQueryRandom',
                'protectedtitles' => 'ApiQueryProtectedTitles',
        )

Definition at line 62 of file ApiQuery.php.

ApiQuery::$mQueryMetaModules [private]

Initial value:

 array (
                'siteinfo' => 'ApiQuerySiteinfo',
                'userinfo' => 'ApiQueryUserInfo',
                'allmessages' => 'ApiQueryAllmessages',
        )

Definition at line 87 of file ApiQuery.php.

ApiQuery::$mQueryPropModules [private]

Initial value:

 array (
                'info' => 'ApiQueryInfo',
                'revisions' => 'ApiQueryRevisions',
                'links' => 'ApiQueryLinks',
                'langlinks' => 'ApiQueryLangLinks',
                'images' => 'ApiQueryImages',
                'imageinfo' => 'ApiQueryImageInfo',
                'templates' => 'ApiQueryLinks',
                'categories' => 'ApiQueryCategories',
                'extlinks' => 'ApiQueryExternalLinks',
                'categoryinfo' => 'ApiQueryCategoryInfo',
                'duplicatefiles' => 'ApiQueryDuplicateFiles',
        )

Definition at line 48 of file ApiQuery.php.

ApiQuery::$mSlaveDB = null [private]

Definition at line 93 of file ApiQuery.php.

ApiQuery::$params [private]

Definition at line 46 of file ApiQuery.php.

Referenced by execute().

ApiQuery::$redirect [private]

Definition at line 46 of file ApiQuery.php.


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

Generated on Sat Apr 30 22:57:31 2011 for MediaWiki by  doxygen 1.5.9