MediaWiki
REL1_22
|
This class contains a list of pages that the client has requested. More...
Public Member Functions | |
__construct (ApiBase $dbSource, $flags=0, $defaultNamespace=NS_MAIN) | |
Constructor. | |
execute () | |
Populate the PageSet from the request parameters. | |
executeDryRun () | |
In case execute() is not called, call this method to mark all relevant parameters as used This prevents unused parameters from being reported as warnings. | |
finishPageSetGeneration () | |
Do not use, does nothing, will be removed. | |
getAllowedParams ($flags=0) | |
getAllTitlesByNamespace () | |
Returns an array [ns][dbkey] => page_id for all requested titles. | |
getCacheMode ($params=null) | |
Get the cache mode for the data generated by this module. | |
getConvertedTitles () | |
Get a list of title conversions - maps a title to its converted version. | |
getConvertedTitlesAsResult ($result=null) | |
Get a list of title conversions - maps a title to its converted version as a result array. | |
getCustomField ($fieldName) | |
Get the value of a custom field previously requested through requestField() | |
getDataSource () | |
Return the parameter name that is the source of data for this PageSet. | |
getGoodTitleCount () | |
Returns the number of found unique pages (not revisions) in the set. | |
getGoodTitles () | |
Title objects that were found in the database. | |
getInterwikiTitles () | |
Get a list of interwiki titles - maps a title to its interwiki prefix. | |
getInterwikiTitlesAsResult ($result=null, $iwUrl=false) | |
Get a list of interwiki titles - maps a title to its interwiki prefix as result. | |
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. | |
getMissingRevisionIDs () | |
Revision IDs that were not found in the database. | |
getMissingRevisionIDsAsResult ($result=null) | |
Revision IDs that were not found in the database as result array. | |
getMissingTitles () | |
Title objects that were NOT found in the database. | |
getNormalizedTitles () | |
Get a list of title normalizations - maps a title to its normalized version. | |
getNormalizedTitlesAsResult ($result=null) | |
Get a list of title normalizations - maps a title to its normalized version in the form of result array. | |
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. | |
getParamDescription () | |
Returns an array of parameter descriptions. | |
getPossibleErrors () | |
Returns a list of all possible errors returned by the module. | |
getRedirectTitles () | |
Get a list of redirect resolutions - maps a title to its redirect target, as an array of output-ready arrays. | |
getRedirectTitlesAsResult ($result=null) | |
Get a list of redirect resolutions - maps a title to its redirect target. | |
getRevisionCount () | |
Returns the number of revisions (requested with revids= parameter). | |
getRevisionIDs () | |
Get the list of revision IDs (requested with the revids= parameter) | |
getSpecialTitles () | |
Get the list of titles with negative namespace. | |
getTitleCount () | |
Returns the number of unique pages (not revisions) in the set. | |
getTitles () | |
All Title objects provided. | |
isResolvingRedirects () | |
Check whether this PageSet is resolving redirects. | |
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. | |
populateFromTitles ($titles) | |
Populate this PageSet from a list of Titles. | |
processDbRow ($row) | |
Extract all requested fields from the row received from the database. | |
requestField ($fieldName) | |
Request an additional field from the page table. | |
Public Attributes | |
const | DISABLE_GENERATORS = 1 |
Constructor flag: The new instance of ApiPageSet will ignore the 'generator=' parameter. | |
Protected Member Functions | |
getDB () | |
Get the database connection (read-only) | |
Private Member Functions | |
executeInternal ($isDryRun) | |
Populate the PageSet from the request parameters. | |
getGenerators () | |
Get an array of all available generators. | |
getRedirectTargets () | |
Get the targets of the pending redirects from the database. | |
initFromPageIds ($pageids) | |
Does the same as initFromTitles(), but is based on page IDs instead. | |
initFromQueryResult ($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. | |
initFromTitles ($titles) | |
This method populates internal variables with page information based on the given array of title strings. | |
processTitlesArray ($titles) | |
Given an array of title strings, convert them into Title objects. | |
resolvePendingRedirects () | |
Resolve any redirects in the result if redirect resolution was requested. | |
Static Private Member Functions | |
static | getPositiveIntegers ($array) |
Returns the input array of integers with all values < 0 removed. | |
Private Attributes | |
$mAllowGenerator | |
$mAllPages = array() | |
$mCacheMode = 'public' | |
$mConvertedTitles = array() | |
$mConvertTitles | |
$mDbSource | |
int | $mDefaultNamespace = NS_MAIN |
$mFakePageId = -1 | |
$mGoodRevIDs = array() | |
$mGoodTitles = array() | |
$mInterwikiTitles = array() | |
$mInvalidTitles = array() | |
$mMissingPageIDs = array() | |
$mMissingRevIDs = array() | |
$mMissingTitles = array() | |
$mNormalizedTitles = array() | |
$mParams | |
$mPendingRedirectIDs = array() | |
$mRedirectTitles = array() | |
$mRequestedPageFields = array() | |
$mResolveRedirects | |
$mSpecialTitles = array() | |
$mTitles = array() | |
Static Private Attributes | |
static | $generators = null |
This class contains a list of pages that the client has requested.
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 41 of file ApiPageSet.php.
ApiPageSet::__construct | ( | ApiBase $ | dbSource, |
$ | flags = 0 , |
||
$ | defaultNamespace = NS_MAIN |
||
) |
Constructor.
$dbSource | ApiBase Module implementing getDB(). Allows PageSet to reuse existing db connection from the shared state like ApiQuery. | |
int | $flags | Zero or more flags like DISABLE_GENERATORS |
int | $defaultNamespace | the namespace to use if none is specified by a prefix. |
Definition at line 84 of file ApiPageSet.php.
Populate the PageSet from the request parameters.
Reimplemented from ApiBase.
Definition at line 108 of file ApiPageSet.php.
In case execute() is not called, call this method to mark all relevant parameters as used This prevents unused parameters from being reported as warnings.
Definition at line 101 of file ApiPageSet.php.
ApiPageSet::executeInternal | ( | $ | isDryRun | ) | [private] |
Populate the PageSet from the request parameters.
bool | $isDryRun | If true, instantiates generator, but only to mark relevant parameters as used |
Definition at line 116 of file ApiPageSet.php.
Do not use, does nothing, will be removed.
Definition at line 611 of file ApiPageSet.php.
ApiPageSet::getAllowedParams | ( | $ | flags = 0 | ) |
Definition at line 1017 of file ApiPageSet.php.
References $flags, $result, array(), ApiBase\GET_VALUES_FOR_HELP, getGenerators(), ApiBase\PARAM_ISMULTI, and ApiBase\PARAM_TYPE.
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 300 of file ApiPageSet.php.
ApiPageSet::getCacheMode | ( | $ | params = null | ) |
Get the cache mode for the data generated by this module.
All PageSet users should take into account whether this returns a more-restrictive cache mode than the using module itself. 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.
$params |
Definition at line 904 of file ApiPageSet.php.
Get a list of title conversions - maps a title to its converted version.
Definition at line 431 of file ApiPageSet.php.
ApiPageSet::getConvertedTitlesAsResult | ( | $ | result = null | ) |
Get a list of title conversions - maps a title to its converted version as a result array.
$result | ApiResult |
Definition at line 442 of file ApiPageSet.php.
ApiPageSet::getCustomField | ( | $ | fieldName | ) |
Get the value of a custom field previously requested through requestField()
string | $fieldName | Field name |
Definition at line 264 of file ApiPageSet.php.
Return the parameter name that is the source of data for this PageSet.
If multiple source parameters are specified (e.g. titles and pageids), one will be named arbitrarily.
Definition at line 233 of file ApiPageSet.php.
ApiPageSet::getDB | ( | ) | [protected] |
Get the database connection (read-only)
Reimplemented from ApiBase.
Definition at line 994 of file ApiPageSet.php.
ApiPageSet::getGenerators | ( | ) | [private] |
Get an array of all available generators.
Definition at line 1051 of file ApiPageSet.php.
Referenced by getAllowedParams().
Returns the number of found unique pages (not revisions) in the set.
Definition at line 332 of file ApiPageSet.php.
Title objects that were found in the database.
Definition at line 324 of file ApiPageSet.php.
Get a list of interwiki titles - maps a title to its interwiki prefix.
Definition at line 461 of file ApiPageSet.php.
ApiPageSet::getInterwikiTitlesAsResult | ( | $ | result = null , |
$ | iwUrl = false |
||
) |
Get a list of interwiki titles - maps a title to its interwiki prefix as result.
$result | ApiResult |
$iwUrl | boolean |
Definition at line 473 of file ApiPageSet.php.
Titles that were deemed invalid by Title::newFromText() The array's index will be unique and negative for each item.
Definition at line 350 of file ApiPageSet.php.
Page IDs that were not found in the database.
Definition at line 358 of file ApiPageSet.php.
Revision IDs that were not found in the database.
Definition at line 504 of file ApiPageSet.php.
ApiPageSet::getMissingRevisionIDsAsResult | ( | $ | result = null | ) |
Revision IDs that were not found in the database as result array.
$result | ApiResult |
Definition at line 514 of file ApiPageSet.php.
Title objects that were NOT found in the database.
The array's index will be negative for each item
Definition at line 341 of file ApiPageSet.php.
Get a list of title normalizations - maps a title to its normalized version.
Definition at line 401 of file ApiPageSet.php.
ApiPageSet::getNormalizedTitlesAsResult | ( | $ | result = null | ) |
Get a list of title normalizations - maps a title to its normalized version in the form of result array.
$result | ApiResult |
Definition at line 412 of file ApiPageSet.php.
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 274 of file ApiPageSet.php.
Returns an array of parameter descriptions.
Don't call this function directly: use getFinalParamDescription() to allow hooks to modify descriptions as needed.
Reimplemented from ApiBase.
Definition at line 1072 of file ApiPageSet.php.
References LanguageConverter\$languagesWithVariants, and array().
static ApiPageSet::getPositiveIntegers | ( | $ | array | ) | [static, private] |
Returns the input array of integers with all values < 0 removed.
$array | array |
Definition at line 1004 of file ApiPageSet.php.
Returns a list of all possible errors returned by the module.
Don't call this function directly: use getFinalPossibleErrors() to allow hooks to modify parameters as needed.
Reimplemented from ApiBase.
Definition at line 1085 of file ApiPageSet.php.
References array().
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 845 of file ApiPageSet.php.
Get a list of redirect resolutions - maps a title to its redirect target, as an array of output-ready arrays.
Definition at line 367 of file ApiPageSet.php.
ApiPageSet::getRedirectTitlesAsResult | ( | $ | result = null | ) |
Get a list of redirect resolutions - maps a title to its redirect target.
$result | ApiResult |
Definition at line 378 of file ApiPageSet.php.
Returns the number of revisions (requested with revids= parameter).
Definition at line 539 of file ApiPageSet.php.
Get the list of revision IDs (requested with the revids= parameter)
Definition at line 496 of file ApiPageSet.php.
Get the list of titles with negative namespace.
Definition at line 531 of file ApiPageSet.php.
Returns the number of unique pages (not revisions) in the set.
Definition at line 316 of file ApiPageSet.php.
All Title objects provided.
Definition at line 308 of file ApiPageSet.php.
ApiPageSet::initFromPageIds | ( | $ | pageids | ) | [private] |
Does the same as initFromTitles(), but is based on page IDs instead.
array | $pageids | of page IDs |
Definition at line 658 of file ApiPageSet.php.
ApiPageSet::initFromQueryResult | ( | $ | 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.
$res | ResultWrapper DB Query result | |
array | $remaining | of either pageID or ns/title elements (optional). If given, any missing items will go to $mMissingPageIDs and $mMissingTitles |
bool | $processTitles | 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 698 of file ApiPageSet.php.
ApiPageSet::initFromRevIDs | ( | $ | revids | ) | [private] |
Does the same as initFromTitles(), but is based on revision IDs instead.
array | $revids | of revision IDs |
Definition at line 765 of file ApiPageSet.php.
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
array | $titles | of Title objects or strings |
Definition at line 631 of file ApiPageSet.php.
Check whether this PageSet is resolving redirects.
Definition at line 221 of file ApiPageSet.php.
ApiPageSet::populateFromPageIDs | ( | $ | pageIDs | ) |
Populate this PageSet from a list of page IDs.
array | $pageIDs | of page IDs |
Definition at line 557 of file ApiPageSet.php.
ApiPageSet::populateFromQueryResult | ( | $ | db, |
$ | queryResult | ||
) |
Populate this PageSet from a rowset returned from the database.
$db | DatabaseBase object |
$queryResult | ResultWrapper Query result object |
Definition at line 568 of file ApiPageSet.php.
ApiPageSet::populateFromRevisionIDs | ( | $ | revIDs | ) |
Populate this PageSet from a list of revision IDs.
array | $revIDs | of revision IDs |
Definition at line 578 of file ApiPageSet.php.
ApiPageSet::populateFromTitles | ( | $ | titles | ) |
Populate this PageSet from a list of Titles.
array | $titles | of Title objects |
Definition at line 547 of file ApiPageSet.php.
ApiPageSet::processDbRow | ( | $ | row | ) |
Extract all requested fields from the row received from the database.
$row | Result row |
Definition at line 588 of file ApiPageSet.php.
ApiPageSet::processTitlesArray | ( | $ | titles | ) | [private] |
Given an array of title strings, convert them into Title objects.
Alternatively, an array of Title objects may be given. This method validates access rights for the title, and appends normalization values to the output.
array | $titles | of Title objects or strings |
Definition at line 917 of file ApiPageSet.php.
ApiPageSet::requestField | ( | $ | fieldName | ) |
Request an additional field from the page table.
Must be called before execute()
string | $fieldName | Field name |
Definition at line 254 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 806 of file ApiPageSet.php.
ApiPageSet::$generators = null [static, private] |
Definition at line 1045 of file ApiPageSet.php.
ApiPageSet::$mAllowGenerator [private] |
Definition at line 53 of file ApiPageSet.php.
ApiPageSet::$mAllPages = array() [private] |
Definition at line 55 of file ApiPageSet.php.
ApiPageSet::$mCacheMode = 'public' [private] |
Definition at line 70 of file ApiPageSet.php.
ApiPageSet::$mConvertedTitles = array() [private] |
Definition at line 66 of file ApiPageSet.php.
ApiPageSet::$mConvertTitles [private] |
Definition at line 52 of file ApiPageSet.php.
ApiPageSet::$mDbSource [private] |
Definition at line 49 of file ApiPageSet.php.
int ApiPageSet::$mDefaultNamespace = NS_MAIN [private] |
Definition at line 74 of file ApiPageSet.php.
ApiPageSet::$mFakePageId = -1 [private] |
Definition at line 69 of file ApiPageSet.php.
ApiPageSet::$mGoodRevIDs = array() [private] |
Definition at line 67 of file ApiPageSet.php.
ApiPageSet::$mGoodTitles = array() [private] |
Definition at line 57 of file ApiPageSet.php.
ApiPageSet::$mInterwikiTitles = array() [private] |
Definition at line 64 of file ApiPageSet.php.
ApiPageSet::$mInvalidTitles = array() [private] |
Definition at line 59 of file ApiPageSet.php.
ApiPageSet::$mMissingPageIDs = array() [private] |
Definition at line 60 of file ApiPageSet.php.
ApiPageSet::$mMissingRevIDs = array() [private] |
Definition at line 68 of file ApiPageSet.php.
ApiPageSet::$mMissingTitles = array() [private] |
Definition at line 58 of file ApiPageSet.php.
ApiPageSet::$mNormalizedTitles = array() [private] |
Definition at line 63 of file ApiPageSet.php.
ApiPageSet::$mParams [private] |
Definition at line 50 of file ApiPageSet.php.
ApiPageSet::$mPendingRedirectIDs = array() [private] |
Definition at line 65 of file ApiPageSet.php.
ApiPageSet::$mRedirectTitles = array() [private] |
Definition at line 61 of file ApiPageSet.php.
ApiPageSet::$mRequestedPageFields = array() [private] |
Definition at line 71 of file ApiPageSet.php.
ApiPageSet::$mResolveRedirects [private] |
Definition at line 51 of file ApiPageSet.php.
ApiPageSet::$mSpecialTitles = array() [private] |
Definition at line 62 of file ApiPageSet.php.
ApiPageSet::$mTitles = array() [private] |
Definition at line 56 of file ApiPageSet.php.
const ApiPageSet::DISABLE_GENERATORS = 1 |
Constructor flag: The new instance of ApiPageSet will ignore the 'generator=' parameter.
Definition at line 47 of file ApiPageSet.php.