MediaWiki  REL1_22
ApiPageSet Class Reference

This class contains a list of pages that the client has requested. More...

Inheritance diagram for ApiPageSet:
Collaboration diagram for ApiPageSet:

List of all members.

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

Detailed Description

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.

Since:
1.21 derives from ApiBase instead of ApiQueryBase

Definition at line 41 of file ApiPageSet.php.


Constructor & Destructor Documentation

ApiPageSet::__construct ( ApiBase dbSource,
flags = 0,
defaultNamespace = NS_MAIN 
)

Constructor.

Parameters:
$dbSourceApiBase Module implementing getDB(). Allows PageSet to reuse existing db connection from the shared state like ApiQuery.
int$flagsZero or more flags like DISABLE_GENERATORS
int$defaultNamespacethe namespace to use if none is specified by a prefix.
Since:
1.21 accepts $flags instead of two boolean values

Definition at line 84 of file ApiPageSet.php.


Member Function Documentation

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.

Parameters:
bool$isDryRunIf 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.

Deprecated:
since 1.21

Definition at line 611 of file ApiPageSet.php.

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

Returns:
array

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.

Parameters:
$params
Returns:
string
Since:
1.21

Definition at line 904 of file ApiPageSet.php.

Get a list of title conversions - maps a title to its converted version.

Returns:
array raw_prefixed_title (string) => prefixed_title (string)

Definition at line 431 of file ApiPageSet.php.

Get a list of title conversions - maps a title to its converted version as a result array.

Parameters:
$resultApiResult
Returns:
array of (from, to) strings
Since:
1.21

Definition at line 442 of file ApiPageSet.php.

ApiPageSet::getCustomField ( fieldName)

Get the value of a custom field previously requested through requestField()

Parameters:
string$fieldNameField name
Returns:
mixed Field value

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.

Returns:
string|null

Definition at line 233 of file ApiPageSet.php.

ApiPageSet::getDB ( ) [protected]

Get the database connection (read-only)

Returns:
DatabaseBase

Reimplemented from ApiBase.

Definition at line 994 of file ApiPageSet.php.

Get an array of all available generators.

Returns:
array

Definition at line 1051 of file ApiPageSet.php.

Referenced by getAllowedParams().

Returns the number of found unique pages (not revisions) in the set.

Returns:
int

Definition at line 332 of file ApiPageSet.php.

Title objects that were found in the database.

Returns:
array page_id (int) => Title (obj)

Definition at line 324 of file ApiPageSet.php.

Get a list of interwiki titles - maps a title to its interwiki prefix.

Returns:
array raw_prefixed_title (string) => interwiki_prefix (string)

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.

Parameters:
$resultApiResult
$iwUrlboolean
Returns:
array raw_prefixed_title (string) => interwiki_prefix (string)
Since:
1.21

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.

Returns:
array of strings (not Title objects)

Definition at line 350 of file ApiPageSet.php.

Page IDs that were not found in the database.

Returns:
array of page IDs

Definition at line 358 of file ApiPageSet.php.

Revision IDs that were not found in the database.

Returns:
array of revision IDs

Definition at line 504 of file ApiPageSet.php.

Revision IDs that were not found in the database as result array.

Parameters:
$resultApiResult
Returns:
array of revision IDs
Since:
1.21

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

Returns:
array of Title objects

Definition at line 341 of file ApiPageSet.php.

Get a list of title normalizations - maps a title to its normalized version.

Returns:
array raw_prefixed_title (string) => prefixed_title (string)

Definition at line 401 of file ApiPageSet.php.

Get a list of title normalizations - maps a title to its normalized version in the form of result array.

Parameters:
$resultApiResult
Returns:
array of raw_prefixed_title (string) => prefixed_title (string)
Since:
1.21

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.

Returns:
array of field names

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.

Returns:
array|bool False on no parameter descriptions

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.

Parameters:
$arrayarray
Returns:
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.

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

Reimplemented from ApiBase.

Definition at line 1085 of file ApiPageSet.php.

References array().

Get the targets of the pending redirects from the database.

Also creates entries in the redirect table for redirects that don't have one.

Returns:
LinkBatch

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.

Returns:
array

Definition at line 367 of file ApiPageSet.php.

Get a list of redirect resolutions - maps a title to its redirect target.

Parameters:
$resultApiResult
Returns:
array of prefixed_title (string) => Title object
Since:
1.21

Definition at line 378 of file ApiPageSet.php.

Returns the number of revisions (requested with revids= parameter).

Returns:
int Number of revisions.

Definition at line 539 of file ApiPageSet.php.

Get the list of revision IDs (requested with the revids= parameter)

Returns:
array revID (int) => pageID (int)

Definition at line 496 of file ApiPageSet.php.

Get the list of titles with negative namespace.

Returns:
array Title

Definition at line 531 of file ApiPageSet.php.

Returns the number of unique pages (not revisions) in the set.

Returns:
int

Definition at line 316 of file ApiPageSet.php.

All Title objects provided.

Returns:
array of Title objects

Definition at line 308 of file ApiPageSet.php.

ApiPageSet::initFromPageIds ( pageids) [private]

Does the same as initFromTitles(), but is based on page IDs instead.

Parameters:
array$pageidsof 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.

Parameters:
$resResultWrapper DB Query result
array$remainingof either pageID or ns/title elements (optional). If given, any missing items will go to $mMissingPageIDs and $mMissingTitles
bool$processTitlesMust 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.

Parameters:
array$revidsof 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

Parameters:
array$titlesof Title objects or strings

Definition at line 631 of file ApiPageSet.php.

Check whether this PageSet is resolving redirects.

Returns:
bool

Definition at line 221 of file ApiPageSet.php.

Populate this PageSet from a list of page IDs.

Parameters:
array$pageIDsof page IDs

Definition at line 557 of file ApiPageSet.php.

ApiPageSet::populateFromQueryResult ( db,
queryResult 
)

Populate this PageSet from a rowset returned from the database.

Parameters:
$dbDatabaseBase object
$queryResultResultWrapper Query result object

Definition at line 568 of file ApiPageSet.php.

Populate this PageSet from a list of revision IDs.

Parameters:
array$revIDsof revision IDs

Definition at line 578 of file ApiPageSet.php.

Populate this PageSet from a list of Titles.

Parameters:
array$titlesof Title objects

Definition at line 547 of file ApiPageSet.php.

Extract all requested fields from the row received from the database.

Parameters:
$rowResult 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.

Parameters:
array$titlesof Title objects or strings
Returns:
LinkBatch

Definition at line 917 of file ApiPageSet.php.

ApiPageSet::requestField ( fieldName)

Request an additional field from the page table.

Must be called before execute()

Parameters:
string$fieldNameField name

Definition at line 254 of file ApiPageSet.php.

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.


Member Data Documentation

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.

Constructor flag: The new instance of ApiPageSet will ignore the 'generator=' parameter.

Since:
1.21

Definition at line 47 of file ApiPageSet.php.


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