Inherits ApiQueryBase.
Public Member Functions | |
__construct ($query, $resolveRedirects=false) | |
Constructor. | |
isResolvingRedirects () | |
Check whether this PageSet is resolving redirects. | |
requestField ($fieldName) | |
Request an additional field from the page table. | |
getCustomField ($fieldName) | |
Get the value of a custom field previously requested through requestField(). | |
getPageTableFields () | |
Get the fields that have to be queried from the page table: the ones requested through requestField() and a few basic ones we always need. | |
getAllTitlesByNamespace () | |
Returns an array [ns][dbkey] => page_id for all requested titles. | |
getTitles () | |
All Title objects provided. | |
getTitleCount () | |
Returns the number of unique pages (not revisions) in the set. | |
getGoodTitles () | |
Title objects that were found in the database. | |
getGoodTitleCount () | |
Returns the number of found unique pages (not revisions) in the set. | |
getMissingTitles () | |
Title objects that were NOT found in the database. | |
getInvalidTitles () | |
Titles that were deemed invalid by Title::newFromText() The array's index will be unique and negative for each item. | |
getMissingPageIDs () | |
Page IDs that were not found in the database. | |
getRedirectTitles () | |
Get a list of redirect resolutions - maps a title to its redirect target. | |
getNormalizedTitles () | |
Get a list of title normalizations - maps a title to its normalized version. | |
getInterwikiTitles () | |
Get a list of interwiki titles - maps a title to its interwiki prefix. | |
getRevisionIDs () | |
Get the list of revision IDs (requested with the revids= parameter). | |
getMissingRevisionIDs () | |
Revision IDs that were not found in the database. | |
getRevisionCount () | |
Returns the number of revisions (requested with revids= parameter)\. | |
execute () | |
Populate the PageSet from the request parameters. | |
populateFromTitles ($titles) | |
Populate this PageSet from a list of Titles. | |
populateFromPageIDs ($pageIDs) | |
Populate this PageSet from a list of page IDs. | |
populateFromQueryResult ($db, $queryResult) | |
Populate this PageSet from a rowset returned from the database. | |
populateFromRevisionIDs ($revIDs) | |
Populate this PageSet from a list of revision IDs. | |
processDbRow ($row) | |
Extract all requested fields from the row received from the database. | |
finishPageSetGeneration () | |
Resolve redirects, if applicable. | |
getVersion () | |
Returns a string that identifies the version of the extending class. | |
Protected Member Functions | |
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. | |
getParamDescription () | |
Returns an array of parameter descriptions. | |
Private Member Functions | |
initFromTitles ($titles) | |
This method populates internal variables with page information based on the given array of title strings. | |
initFromPageIds ($pageids) | |
Does the same as initFromTitles(), but is based on page IDs instead. | |
initFromQueryResult ($db, $res, &$remaining=null, $processTitles=null) | |
Iterate through the result of the query on 'page' table, and for each row create and store title object and save any extra fields requested. | |
initFromRevIDs ($revids) | |
Does the same as initFromTitles(), but is based on revision IDs instead. | |
resolvePendingRedirects () | |
Resolve any redirects in the result if redirect resolution was requested. | |
getRedirectTargets () | |
Get the targets of the pending redirects from the database. | |
processTitlesArray ($titles) | |
Given an array of title strings, convert them into Title objects. | |
Private Attributes | |
$mAllPages | |
$mTitles | |
$mGoodTitles | |
$mMissingTitles | |
$mInvalidTitles | |
$mMissingPageIDs | |
$mRedirectTitles | |
$mNormalizedTitles | |
$mInterwikiTitles | |
$mResolveRedirects | |
$mPendingRedirectIDs | |
$mGoodRevIDs | |
$mMissingRevIDs | |
$mFakePageId | |
$mRequestedPageFields |
Initially, when the client passes in titles=, pageids=, or revisions= parameter, an instance of the ApiPageSet class will normalize titles, determine if the pages/revisions exist, and prefetch any additional page data requested.
When a generator is used, the result of the generator will become the input for the second instance of this class, and all subsequent actions will use the second instance for all their work.
Definition at line 44 of file ApiPageSet.php.
ApiPageSet::__construct | ( | $ | query, | |
$ | resolveRedirects = false | |||
) |
Constructor.
$query | ApiQuery | |
$resolveRedirects | bool Whether redirects should be resolved |
Definition at line 61 of file ApiPageSet.php.
ApiPageSet::execute | ( | ) |
Populate the PageSet from the request parameters.
Reimplemented from ApiBase.
Definition at line 258 of file ApiPageSet.php.
References ApiBase::dieUsage(), ApiBase::extractRequestParams(), initFromPageIds(), initFromRevIDs(), initFromTitles(), ApiBase::profileIn(), ApiBase::profileOut(), and ApiBase::setWarning().
ApiPageSet::finishPageSetGeneration | ( | ) |
Resolve redirects, if applicable.
Definition at line 365 of file ApiPageSet.php.
References ApiBase::profileIn(), ApiBase::profileOut(), and resolvePendingRedirects().
ApiPageSet::getAllowedParams | ( | ) | [protected] |
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.
Reimplemented from ApiBase.
Definition at line 670 of file ApiPageSet.php.
References ApiBase::PARAM_ISMULTI, and ApiBase::PARAM_TYPE.
ApiPageSet::getAllTitlesByNamespace | ( | ) |
Returns an array [ns][dbkey] => page_id for all requested titles.
page_id is a unique negative number in case title was not found. Invalid titles will also have negative page IDs and will be in namespace 0
Definition at line 142 of file ApiPageSet.php.
ApiPageSet::getCustomField | ( | $ | fieldName | ) |
Get the value of a custom field previously requested through requestField().
$fieldName | string Field name |
Definition at line 107 of file ApiPageSet.php.
ApiPageSet::getGoodTitleCount | ( | ) |
Returns the number of found unique pages (not revisions) in the set.
Definition at line 174 of file ApiPageSet.php.
ApiPageSet::getGoodTitles | ( | ) |
Title objects that were found in the database.
Definition at line 166 of file ApiPageSet.php.
ApiPageSet::getInterwikiTitles | ( | ) |
Get a list of interwiki titles - maps a title to its interwiki prefix.
Definition at line 227 of file ApiPageSet.php.
ApiPageSet::getInvalidTitles | ( | ) |
Titles that were deemed invalid by Title::newFromText() The array's index will be unique and negative for each item.
Definition at line 192 of file ApiPageSet.php.
ApiPageSet::getMissingPageIDs | ( | ) |
Page IDs that were not found in the database.
Definition at line 200 of file ApiPageSet.php.
ApiPageSet::getMissingRevisionIDs | ( | ) |
Revision IDs that were not found in the database.
Definition at line 243 of file ApiPageSet.php.
ApiPageSet::getMissingTitles | ( | ) |
Title objects that were NOT found in the database.
The array's index will be negative for each item
Definition at line 183 of file ApiPageSet.php.
ApiPageSet::getNormalizedTitles | ( | ) |
Get a list of title normalizations - maps a title to its normalized version.
Definition at line 218 of file ApiPageSet.php.
ApiPageSet::getPageTableFields | ( | ) |
Get the fields that have to be queried from the page table: the ones requested through requestField() and a few basic ones we always need.
Definition at line 117 of file ApiPageSet.php.
Referenced by initFromPageIds(), initFromTitles(), and resolvePendingRedirects().
ApiPageSet::getParamDescription | ( | ) | [protected] |
Returns an array of parameter descriptions.
Don't call this functon directly: use getFinalParamDescription() to allow hooks to modify descriptions as needed.
Reimplemented from ApiBase.
Definition at line 686 of file ApiPageSet.php.
ApiPageSet::getRedirectTargets | ( | ) | [private] |
Get the targets of the pending redirects from the database.
Also creates entries in the redirect table for redirects that don't have one.
Definition at line 576 of file ApiPageSet.php.
References $db, $lb, $res, $row, $title, ApiQueryBase::getDB(), Title::makeTitle(), ApiBase::profileDBIn(), and ApiBase::profileDBOut().
Referenced by resolvePendingRedirects().
ApiPageSet::getRedirectTitles | ( | ) |
Get a list of redirect resolutions - maps a title to its redirect target.
Definition at line 209 of file ApiPageSet.php.
ApiPageSet::getRevisionCount | ( | ) |
Returns the number of revisions (requested with revids= parameter)\.
Definition at line 251 of file ApiPageSet.php.
References getRevisionIDs().
ApiPageSet::getRevisionIDs | ( | ) |
Get the list of revision IDs (requested with the revids= parameter).
Definition at line 235 of file ApiPageSet.php.
Referenced by getRevisionCount().
ApiPageSet::getTitleCount | ( | ) |
Returns the number of unique pages (not revisions) in the set.
Definition at line 158 of file ApiPageSet.php.
ApiPageSet::getTitles | ( | ) |
All Title objects provided.
Definition at line 150 of file ApiPageSet.php.
ApiPageSet::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
Reimplemented from ApiBase.
Definition at line 694 of file ApiPageSet.php.
ApiPageSet::initFromPageIds | ( | $ | pageids | ) | [private] |
Does the same as initFromTitles(), but is based on page IDs instead.
$pageids | array of page IDs |
Definition at line 414 of file ApiPageSet.php.
References $db, $res, ApiQueryBase::getDB(), getPageTableFields(), initFromQueryResult(), ApiBase::profileDBIn(), ApiBase::profileDBOut(), and resolvePendingRedirects().
Referenced by execute(), initFromRevIDs(), and populateFromPageIDs().
ApiPageSet::initFromQueryResult | ( | $ | db, | |
$ | res, | |||
&$ | remaining = null , |
|||
$ | processTitles = null | |||
) | [private] |
Iterate through the result of the query on 'page' table, and for each row create and store title object and save any extra fields requested.
$db | Database | |
$res | DB Query result | |
$remaining | array of either pageID or ns/title elements (optional). If given, any missing items will go to $mMissingPageIDs and $mMissingTitles | |
$processTitles | bool Must be provided together with $remaining. If true, treat $remaining as an array of [ns][title] If false, treat it as an array of [pageIDs] |
Definition at line 448 of file ApiPageSet.php.
References $db, $ns, $res, $row, $title, ApiBase::dieDebug(), Title::makeTitle(), and processDbRow().
Referenced by initFromPageIds(), initFromTitles(), populateFromQueryResult(), and resolvePendingRedirects().
ApiPageSet::initFromRevIDs | ( | $ | revids | ) | [private] |
Does the same as initFromTitles(), but is based on revision IDs instead.
$revids | array of revision IDs |
Definition at line 499 of file ApiPageSet.php.
References $db, ApiQueryBase::$fields, $res, $row, ApiQueryBase::$tables, ApiQueryBase::$where, ApiQueryBase::getDB(), initFromPageIds(), ApiBase::profileDBIn(), and ApiBase::profileDBOut().
Referenced by execute(), and populateFromRevisionIDs().
ApiPageSet::initFromTitles | ( | $ | titles | ) | [private] |
This method populates internal variables with page information based on the given array of title strings.
Steps: #1 For each title, get data from `page` table #2 If page was not found in the DB, store it as missing
Additionally, when resolving redirects: #3 If no more redirects left, stop. #4 For each redirect, get its target from the `redirect` table. #5 Substitute the original LinkBatch object with the new list #6 Repeat from step #1
$titles | array of Title objects or strings |
Definition at line 387 of file ApiPageSet.php.
References $db, $res, ApiQueryBase::getDB(), getPageTableFields(), initFromQueryResult(), processTitlesArray(), ApiBase::profileDBIn(), ApiBase::profileDBOut(), and resolvePendingRedirects().
Referenced by execute(), and populateFromTitles().
ApiPageSet::isResolvingRedirects | ( | ) |
Check whether this PageSet is resolving redirects.
Definition at line 88 of file ApiPageSet.php.
ApiPageSet::populateFromPageIDs | ( | $ | pageIDs | ) |
Populate this PageSet from a list of page IDs.
$pageIDs | array of page IDs |
Definition at line 312 of file ApiPageSet.php.
References initFromPageIds(), ApiBase::profileIn(), and ApiBase::profileOut().
ApiPageSet::populateFromQueryResult | ( | $ | db, | |
$ | queryResult | |||
) |
Populate this PageSet from a rowset returned from the database.
$db | Database object | |
$queryResult | Query result object |
Definition at line 323 of file ApiPageSet.php.
References $db, initFromQueryResult(), ApiBase::profileIn(), and ApiBase::profileOut().
ApiPageSet::populateFromRevisionIDs | ( | $ | revIDs | ) |
Populate this PageSet from a list of revision IDs.
$revIDs | array of revision IDs |
Definition at line 333 of file ApiPageSet.php.
References initFromRevIDs(), ApiBase::profileIn(), and ApiBase::profileOut().
ApiPageSet::populateFromTitles | ( | $ | titles | ) |
Populate this PageSet from a list of Titles.
$titles | array of Title objects |
Definition at line 302 of file ApiPageSet.php.
References initFromTitles(), ApiBase::profileIn(), and ApiBase::profileOut().
ApiPageSet::processDbRow | ( | $ | row | ) |
Extract all requested fields from the row received from the database.
$row | Result row |
Definition at line 343 of file ApiPageSet.php.
References $row, $title, and Title::makeTitle().
Referenced by initFromQueryResult().
ApiPageSet::processTitlesArray | ( | $ | titles | ) | [private] |
Given an array of title strings, convert them into Title objects.
Alternativelly, an array of Title objects may be given. This method validates access rights for the title, and appends normalization values to the output.
$titles | array of Title objects or strings |
Definition at line 629 of file ApiPageSet.php.
References $title, Title::newFromText(), and ApiBase::setWarning().
Referenced by initFromTitles().
ApiPageSet::requestField | ( | $ | fieldName | ) |
Request an additional field from the page table.
Must be called before execute()
$fieldName | string Field name |
Definition at line 97 of file ApiPageSet.php.
ApiPageSet::resolvePendingRedirects | ( | ) | [private] |
Resolve any redirects in the result if redirect resolution was requested.
This function is called repeatedly until all redirects have been resolved.
Definition at line 537 of file ApiPageSet.php.
References $db, $res, ApiQueryBase::getDB(), getPageTableFields(), getRedirectTargets(), initFromQueryResult(), ApiBase::profileDBIn(), and ApiBase::profileDBOut().
Referenced by finishPageSetGeneration(), initFromPageIds(), and initFromTitles().
ApiPageSet::$mAllPages [private] |
Definition at line 46 of file ApiPageSet.php.
ApiPageSet::$mFakePageId [private] |
Definition at line 52 of file ApiPageSet.php.
ApiPageSet::$mGoodRevIDs [private] |
Definition at line 51 of file ApiPageSet.php.
ApiPageSet::$mGoodTitles [private] |
Definition at line 47 of file ApiPageSet.php.
ApiPageSet::$mInterwikiTitles [private] |
Definition at line 49 of file ApiPageSet.php.
ApiPageSet::$mInvalidTitles [private] |
Definition at line 47 of file ApiPageSet.php.
ApiPageSet::$mMissingPageIDs [private] |
Definition at line 48 of file ApiPageSet.php.
ApiPageSet::$mMissingRevIDs [private] |
Definition at line 51 of file ApiPageSet.php.
ApiPageSet::$mMissingTitles [private] |
Definition at line 47 of file ApiPageSet.php.
ApiPageSet::$mNormalizedTitles [private] |
Definition at line 49 of file ApiPageSet.php.
ApiPageSet::$mPendingRedirectIDs [private] |
Definition at line 50 of file ApiPageSet.php.
ApiPageSet::$mRedirectTitles [private] |
Definition at line 48 of file ApiPageSet.php.
ApiPageSet::$mRequestedPageFields [private] |
Definition at line 54 of file ApiPageSet.php.
ApiPageSet::$mResolveRedirects [private] |
Definition at line 50 of file ApiPageSet.php.
ApiPageSet::$mTitles [private] |
Definition at line 47 of file ApiPageSet.php.