MediaWiki  REL1_19
ApiQueryBase Class Reference

This is a base class for all Query modules. More...

Inheritance diagram for ApiQueryBase:
Collaboration diagram for ApiQueryBase:

List of all members.

Public Member Functions

 __construct (ApiBase $query, $moduleName, $paramPrefix= '')
 getCacheMode ($params)
 Get the cache mode for the data generated by this module.
 getDirectionDescription ($p= '', $extraDirText= '')
 Gets the personalised direction parameter description.
 getPossibleErrors ()
 getQuery ()
 Get the main Query module.
 keyPartToTitle ($keyPart)
 An alternative to keyToTitle() that doesn't trim trailing spaces.
 keyToTitle ($key)
 The inverse of titleToKey()
 prepareUrlQuerySearchString ($query=null, $protocol=null)
 requestExtraData ($pageSet)
 Override this method to request extra fields from the pageSet using $pageSet->requestField('fieldName')
 selectNamedDB ($name, $db, $groups)
 Selects the query database connection with the given name.
 showHiddenUsersAddBlockInfo ($showBlockInfo)
 Filters hidden users (where the user doesn't have the right to view them) Also adds relevant block information.
 titlePartToKey ($titlePart)
 An alternative to titleToKey() that doesn't trim trailing spaces.
 titleToKey ($title)
 Convert a title to a DB key.
 validateSha1Base36Hash ($hash)
 validateSha1Hash ($hash)

Static Public Member Functions

static addTitleInfo (&$arr, $title, $prefix= '')
 Add information (title and namespace) about a Title object to a result array.
static getBaseVersion ()
 Get version string for use in the API help output.

Public Attributes

 $fields
 $join_conds
 $mDb
 $options
 $tables
 $where

Protected Member Functions

 addFields ($value)
 Add a set of fields to select to the internal array.
 addFieldsIf ($value, $condition)
 Same as addFields(), but add the fields only if a condition is met.
 addJoinConds ($join_conds)
 Add a set of JOIN conditions to the internal array.
 addOption ($name, $value=null)
 Add an option such as LIMIT or USE INDEX.
 addPageSubItem ($pageId, $item, $elemname=null)
 Same as addPageSubItems(), but one element of $data at a time.
 addPageSubItems ($pageId, $data)
 Add a sub-element under the page element with the given page ID.
 addTables ($tables, $alias=null)
 Add a set of tables to the internal array.
 addTimestampWhereRange ($field, $dir, $start, $end, $sort=true)
 Add a WHERE clause corresponding to a range, similar to addWhereRange, but converts $start and $end to database timestamps.
 addWhere ($value)
 Add a set of WHERE clauses to the internal array.
 addWhereFld ($field, $value)
 Equivalent to addWhere(array($field => $value))
 addWhereIf ($value, $condition)
 Same as addWhere(), but add the WHERE clauses only if a condition is met.
 addWhereRange ($field, $dir, $start, $end, $sort=true)
 Add a WHERE clause corresponding to a range, and an ORDER BY clause to sort in the right direction.
 checkRowCount ()
 Estimate the row count for the SELECT query that would be run if we called select() right now, and check if it's acceptable.
 getDB ()
 Get the Query database connection (read-only)
 getPageSet ()
 Get the PageSet object to work on.
 resetQueryParams ()
 Blank the internal arrays with query parameters.
 select ($method, $extraQuery=array())
 Execute a SELECT query based on the values in the internal arrays.
 setContinueEnumParameter ($paramName, $paramValue)
 Set a query-continue value.

Private Attributes

 $mQueryModule

Detailed Description

This is a base class for all Query modules.

It provides some common functionality such as constructing various SQL queries.

Definition at line 34 of file ApiQueryBase.php.


Constructor & Destructor Documentation

ApiQueryBase::__construct ( ApiBase query,
moduleName,
paramPrefix = '' 
)
Parameters:
$queryApiBase
$moduleNamestring
$paramPrefixstring

Definition at line 43 of file ApiQueryBase.php.

References ApiBase\getMain(), and resetQueryParams().

Here is the call graph for this function:


Member Function Documentation

ApiQueryBase::addFieldsIf ( value,
condition 
) [protected]

Same as addFields(), but add the fields only if a condition is met.

Parameters:
$valuearray|string See addFields()
$conditionbool If false, do nothing
Returns:
bool $condition

Definition at line 131 of file ApiQueryBase.php.

References addFields().

Referenced by ApiQueryAllUsers\execute(), ApiQueryDeletedrevs\execute(), ApiQueryFilearchive\execute(), ApiQueryBlocks\execute(), ApiQueryLogEvents\execute(), ApiQueryTags\execute(), ApiQueryContributions\prepareQuery(), ApiQueryProtectedTitles\run(), ApiQueryWatchlistRaw\run(), ApiQueryExtLinksUsage\run(), ApiQueryCategories\run(), ApiQueryAllLinks\run(), ApiQueryCategoryMembers\run(), ApiQueryAllCategories\run(), ApiQueryWatchlist\run(), and ApiQueryRecentChanges\run().

Here is the call graph for this function:

Here is the caller graph for this function:

ApiQueryBase::addJoinConds ( join_conds) [protected]

Add a set of JOIN conditions to the internal array.

JOIN conditions are formatted as array( tablename => array(jointype, conditions) e.g. array('page' => array('LEFT JOIN', 'page_id=rev_page')) . conditions may be a string or an addWhere()-style array

Parameters:
$join_condsarray JOIN conditions

Definition at line 106 of file ApiQueryBase.php.

References $join_conds, and ApiBase\dieDebug().

Referenced by ApiQueryAllUsers\execute(), ApiQueryCategoryInfo\execute(), ApiQueryLogEvents\execute(), ApiQueryUsers\execute(), ApiQueryRevisions\execute(), ApiQueryContributions\prepareQuery(), ApiQueryProtectedTitles\run(), ApiQueryCategories\run(), ApiQueryAllCategories\run(), ApiQueryWatchlist\run(), ApiQueryAllpages\run(), ApiQueryRecentChanges\run(), and showHiddenUsersAddBlockInfo().

Here is the call graph for this function:

Here is the caller graph for this function:

ApiQueryBase::addPageSubItem ( pageId,
item,
elemname = null 
) [protected]

Same as addPageSubItems(), but one element of $data at a time.

Parameters:
$pageIdint Page ID
$itemarray Data array à la ApiResult
$elemnamestring XML element name. If null, getModuleName() is used
Returns:
bool Whether the element fit in the result

Definition at line 348 of file ApiQueryBase.php.

References $result, ApiBase\getModuleName(), ApiBase\getModulePrefix(), and ApiBase\getResult().

Referenced by ApiQueryExternalLinks\execute(), ApiQueryLangLinks\execute(), ApiQueryIWLinks\execute(), ApiQueryImageInfo\execute(), ApiQueryRevisions\execute(), ApiQueryImages\run(), ApiQueryDuplicateFiles\run(), ApiQueryCategories\run(), and ApiQueryLinks\run().

Here is the call graph for this function:

Here is the caller graph for this function:

ApiQueryBase::addPageSubItems ( pageId,
data 
) [protected]

Add a sub-element under the page element with the given page ID.

Parameters:
$pageIdint Page ID
$dataarray Data array à la ApiResult
Returns:
bool Whether the element fit in the result

Definition at line 332 of file ApiQueryBase.php.

References $result, ApiBase\getModuleName(), ApiBase\getModulePrefix(), and ApiBase\getResult().

Referenced by ApiQueryCategoryInfo\execute().

Here is the call graph for this function:

Here is the caller graph for this function:

ApiQueryBase::addTables ( tables,
alias = null 
) [protected]
ApiQueryBase::addTimestampWhereRange ( field,
dir,
start,
end,
sort = true 
) [protected]

Add a WHERE clause corresponding to a range, similar to addWhereRange, but converts $start and $end to database timestamps.

See also:
addWhereRange
Parameters:
$field
$dir
$start
$end
$sortbool

Definition at line 234 of file ApiQueryBase.php.

References $dir, and addWhereRange().

Referenced by ApiQueryDeletedrevs\execute(), ApiQueryBlocks\execute(), ApiQueryLogEvents\execute(), ApiQueryRevisions\execute(), ApiQueryContributions\prepareQuery(), ApiQueryProtectedTitles\run(), ApiQueryWatchlist\run(), and ApiQueryRecentChanges\run().

Here is the call graph for this function:

Here is the caller graph for this function:

ApiQueryBase::addWhere ( value) [protected]
ApiQueryBase::addWhereIf ( value,
condition 
) [protected]

Same as addWhere(), but add the WHERE clauses only if a condition is met.

Parameters:
$valuemixed See addWhere()
$conditionbool If false, do nothing
Returns:
bool $condition

Definition at line 168 of file ApiQueryBase.php.

References addWhere().

Referenced by ApiQueryBlocks\execute(), ApiQueryContributions\prepareQuery(), ApiQueryWatchlistRaw\run(), ApiQueryWatchlist\run(), and ApiQueryRecentChanges\run().

Here is the call graph for this function:

Here is the caller graph for this function:

ApiQueryBase::addWhereRange ( field,
dir,
start,
end,
sort = true 
) [protected]

Add a WHERE clause corresponding to a range, and an ORDER BY clause to sort in the right direction.

Parameters:
$fieldstring Field name
$dirstring If 'newer', sort in ascending order, otherwise sort in descending order
$startstring Value to start the list at. If $dir == 'newer' this is the lower boundary, otherwise it's the upper boundary
$endstring Value to end the list at. If $dir == 'newer' this is the upper boundary, otherwise it's the lower boundary
$sortbool If false, don't add an ORDER BY clause

Definition at line 201 of file ApiQueryBase.php.

References $dir, addOption(), addWhere(), and getDB().

Referenced by addTimestampWhereRange(), ApiQueryAllUsers\execute(), ApiQueryDeletedrevs\execute(), ApiQueryFilearchive\execute(), ApiQueryTags\execute(), ApiQueryRevisions\execute(), ApiQueryRandom\prepareQuery(), ApiQueryContributions\prepareQuery(), ApiQueryAllLinks\run(), ApiQueryAllCategories\run(), ApiQueryCategoryMembers\run(), ApiQueryAllpages\run(), and ApiQueryAllimages\run().

Here is the call graph for this function:

Here is the caller graph for this function:

ApiQueryBase::checkRowCount ( ) [protected]

Estimate the row count for the SELECT query that would be run if we called select() right now, and check if it's acceptable.

Returns:
bool true if acceptable, false otherwise

Definition at line 285 of file ApiQueryBase.php.

References $wgAPIMaxDBRows, getDB(), ApiBase\profileDBIn(), and ApiBase\profileDBOut().

Here is the call graph for this function:

static ApiQueryBase::getBaseVersion ( ) [static]

Get version string for use in the API help output.

Returns:
string

Reimplemented from ApiBase.

Definition at line 562 of file ApiQueryBase.php.

Get the cache mode for the data generated by this module.

Override this in the module subclass. For possible return values and other details about cache modes, see ApiMain::setCacheMode()

Public caching will only be allowed if *all* the modules that supply data for a given request return a cache mode of public.

Parameters:
$params
Returns:
string

Reimplemented in ApiQueryInfo, ApiQuerySiteinfo, ApiQueryRevisions, ApiQueryRecentChanges, ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryContributions, ApiQueryAllUsers, ApiQueryUsers, ApiQuerySearch, ApiQueryAllmessages, ApiQueryIWBacklinks, ApiQueryLangBacklinks, ApiQueryImages, ApiQueryProtectedTitles, ApiQueryQueryPage, ApiQueryRandom, ApiQueryIWLinks, ApiQueryTags, ApiQueryLangLinks, ApiQueryPageProps, ApiQueryBacklinks, ApiQueryExternalLinks, ApiQueryCategoryInfo, ApiQueryLinks, ApiQueryAllimages, ApiQueryAllCategories, ApiQueryAllLinks, ApiQueryAllpages, ApiQueryCategories, ApiQueryCategoryMembers, ApiQueryDuplicateFiles, and ApiQueryExtLinksUsage.

Definition at line 61 of file ApiQueryBase.php.

ApiQueryBase::getDirectionDescription ( p = '',
extraDirText = '' 
)

Gets the personalised direction parameter description.

Parameters:
string$pModulePrefix
string$extraDirTextAny extra text to be appended on the description
Returns:
array

Definition at line 469 of file ApiQueryBase.php.

Referenced by ApiQueryProtectedTitles\getParamDescription(), ApiQueryBlocks\getParamDescription(), ApiQueryDeletedrevs\getParamDescription(), ApiQueryWatchlist\getParamDescription(), ApiQueryContributions\getParamDescription(), ApiQueryLogEvents\getParamDescription(), ApiQueryRecentChanges\getParamDescription(), and ApiQueryRevisions\getParamDescription().

Here is the caller graph for this function:

Get the main Query module.

Returns:
ApiQuery

Definition at line 322 of file ApiQueryBase.php.

Referenced by getDB(), getPageSet(), and selectNamedDB().

Here is the caller graph for this function:

An alternative to keyToTitle() that doesn't trim trailing spaces.

Parameters:
$keyPartstring Key part with spaces
Returns:
string Key part with underscores

Definition at line 458 of file ApiQueryBase.php.

References keyToTitle().

Here is the call graph for this function:

The inverse of titleToKey()

Parameters:
$keystring Page title with underscores
Returns:
string Page title with spaces

Definition at line 431 of file ApiQueryBase.php.

References $t, and ApiBase\dieUsageMsg().

Referenced by ApiQueryAllUsers\execute(), ApiQueryFilearchive\execute(), keyPartToTitle(), ApiQueryDuplicateFiles\run(), ApiQueryAllCategories\run(), ApiQueryAllLinks\run(), ApiQueryAllpages\run(), ApiQueryAllimages\run(), and ApiQueryLinks\run().

Here is the call graph for this function:

Here is the caller graph for this function:

ApiQueryBase::prepareUrlQuerySearchString ( query = null,
protocol = null 
)
Parameters:
$queryString
$protocolString
Returns:
null|string

Definition at line 482 of file ApiQueryBase.php.

References ApiBase\dieUsage(), LinkFilter\keepOneWildcard(), and LinkFilter\makeLikeArray().

Referenced by ApiQueryExternalLinks\execute(), and ApiQueryExtLinksUsage\run().

Here is the call graph for this function:

Here is the caller graph for this function:

Override this method to request extra fields from the pageSet using $pageSet->requestField('fieldName')

Parameters:
$pageSetApiPageSet

Reimplemented in ApiQueryInfo.

Definition at line 315 of file ApiQueryBase.php.

Blank the internal arrays with query parameters.

Definition at line 68 of file ApiQueryBase.php.

Referenced by __construct(), ApiQueryInfo\getDisplayTitle(), ApiQueryInfo\getProtectionInfo(), ApiQueryInfo\getTSIDs(), ApiQueryInfo\getWatchedInfo(), ApiQueryRandom\prepareQuery(), and ApiQueryBacklinks\run().

Here is the caller graph for this function:

ApiQueryBase::select ( method,
extraQuery = array() 
) [protected]

Execute a SELECT query based on the values in the internal arrays.

Parameters:
$methodstring Function the query should be attributed to. You should usually use __METHOD__ here
$extraQueryarray Query data to add but not store in the object Format is array( 'tables' => ..., 'fields' => ..., 'where' => ..., 'options' => ..., 'join_conds' => ... )
Returns:
ResultWrapper

Definition at line 262 of file ApiQueryBase.php.

References $fields, $join_conds, $options, $res, $tables, $where, getDB(), ApiBase\profileDBIn(), and ApiBase\profileDBOut().

Referenced by ApiQueryAllUsers\execute(), ApiQueryCategoryInfo\execute(), ApiQueryDeletedrevs\execute(), ApiQueryExternalLinks\execute(), ApiQueryLangLinks\execute(), ApiQueryIWLinks\execute(), ApiQueryPageProps\execute(), ApiQueryFilearchive\execute(), ApiQueryContributions\execute(), ApiQueryBlocks\execute(), ApiQueryLogEvents\execute(), ApiQueryTags\execute(), ApiQueryUsers\execute(), ApiQueryRevisions\execute(), ApiQueryInfo\getDisplayTitle(), ApiQueryInfo\getProtectionInfo(), ApiQueryInfo\getTSIDs(), ApiQueryInfo\getWatchedInfo(), ApiQueryImages\run(), ApiQueryIWBacklinks\run(), ApiQueryLangBacklinks\run(), ApiQueryProtectedTitles\run(), ApiQueryWatchlistRaw\run(), ApiQueryExtLinksUsage\run(), ApiQueryCategoryMembers\run(), ApiQueryCategories\run(), ApiQueryAllLinks\run(), ApiQueryDuplicateFiles\run(), ApiQueryAllCategories\run(), ApiQueryWatchlist\run(), ApiQueryAllpages\run(), ApiQueryAllimages\run(), ApiQueryLinks\run(), ApiQueryRecentChanges\run(), ApiQueryBacklinks\run(), and ApiQueryRandom\runQuery().

Here is the call graph for this function:

Here is the caller graph for this function:

ApiQueryBase::selectNamedDB ( name,
db,
groups 
)

Selects the query database connection with the given name.

See ApiQuery::getNamedDB() for more information

Parameters:
$namestring Name to assign to the database connection
$dbint One of the DB_* constants
$groupsarray Query groups
Returns:
Database

Definition at line 397 of file ApiQueryBase.php.

References getQuery().

Referenced by ApiQueryContributions\execute(), ApiQueryWatchlistRaw\run(), and ApiQueryWatchlist\run().

Here is the call graph for this function:

Here is the caller graph for this function:

Filters hidden users (where the user doesn't have the right to view them) Also adds relevant block information.

Parameters:
bool$showBlockInfo
Returns:
void

Definition at line 510 of file ApiQueryBase.php.

References addFields(), addJoinConds(), addTables(), addWhere(), and ContextSource\getUser().

Referenced by ApiQueryAllUsers\execute(), and ApiQueryUsers\execute().

Here is the call graph for this function:

Here is the caller graph for this function:

ApiQueryBase::titlePartToKey ( titlePart)

An alternative to titleToKey() that doesn't trim trailing spaces.

Parameters:
$titlePartstring Title part with spaces
Returns:
string Title part with underscores

Definition at line 449 of file ApiQueryBase.php.

References titleToKey().

Referenced by ApiQueryFilearchive\execute(), ApiQueryAllCategories\run(), ApiQueryAllLinks\run(), ApiQueryAllpages\run(), and ApiQueryAllimages\run().

Here is the call graph for this function:

Here is the caller graph for this function:

Convert a title to a DB key.

Parameters:
$titlestring Page title with spaces
Returns:
string Page title with underscores

Definition at line 414 of file ApiQueryBase.php.

References $t, $title, ApiBase\dieUsageMsg(), and Title\newFromText().

Referenced by ApiQueryDeletedrevs\execute(), ApiQueryIWLinks\execute(), ApiQueryImages\run(), ApiQueryLangBacklinks\run(), ApiQueryIWBacklinks\run(), ApiQueryWatchlistRaw\run(), ApiQueryDuplicateFiles\run(), ApiQueryAllLinks\run(), ApiQueryCategories\run(), ApiQueryLinks\run(), and titlePartToKey().

Here is the call graph for this function:

Here is the caller graph for this function:

Parameters:
$hashstring
Returns:
bool

Definition at line 544 of file ApiQueryBase.php.

Referenced by ApiQueryFilearchive\execute(), and ApiQueryAllimages\run().

Here is the caller graph for this function:

Parameters:
$hashstring
Returns:
bool

Definition at line 536 of file ApiQueryBase.php.

Referenced by ApiQueryFilearchive\execute(), and ApiQueryAllimages\run().

Here is the caller graph for this function:


Member Data Documentation

ApiQueryBase::$fields

Definition at line 36 of file ApiQueryBase.php.

Referenced by ApiPageSet\initFromRevIDs(), and select().

ApiQueryBase::$join_conds

Definition at line 36 of file ApiQueryBase.php.

Referenced by addJoinConds(), and select().

ApiQueryBase::$mDb

Definition at line 36 of file ApiQueryBase.php.

ApiQueryBase::$mQueryModule [private]

Definition at line 36 of file ApiQueryBase.php.

ApiQueryBase::$options

Definition at line 36 of file ApiQueryBase.php.

Referenced by select().

ApiQueryBase::$tables
ApiQueryBase::$where

Definition at line 36 of file ApiQueryBase.php.

Referenced by ApiQueryDeletedrevs\execute(), ApiPageSet\initFromRevIDs(), and select().


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