MediaWiki  REL1_24
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)
 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.
 getInvalidTitlesAndRevisions ($invalidChecks=array( 'invalidTitles','special', 'missingIds', 'missingRevIds', 'missingTitles', 'interwikiTitles'))
 Get an array of invalid/special/missing titles.
 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.
 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 addValues (array &$result, $values, $flag=null, $name=null)
 Add all items from $values into the result.
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
Title[] $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 
)
Parameters:
ApiBase$dbSourceModule 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 104 of file ApiPageSet.php.


Member Function Documentation

static ApiPageSet::addValues ( array &$  result,
values,
flag = null,
name = null 
) [static, private]

Add all items from $values into the result.

Parameters:
array$resultOutput
array$valuesValues to add
string$flagThe name of the boolean flag to mark this element
string$nameIf given, name of the value

Definition at line 80 of file ApiPageSet.php.

Populate the PageSet from the request parameters.

Reimplemented from ApiBase.

Definition at line 128 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 121 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 137 of file ApiPageSet.php.

Do not use, does nothing, will be removed.

Deprecated:
since 1.21

Definition at line 680 of file ApiPageSet.php.

ApiPageSet::getAllowedParams ( flags = 0)

Definition at line 1093 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 324 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:
array | null$params
Returns:
string
Since:
1.21

Definition at line 979 of file ApiPageSet.php.

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

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

Definition at line 457 of file ApiPageSet.php.

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

Parameters:
ApiResult$result
Returns:
array Array of (from, to) strings
Since:
1.21

Definition at line 468 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 287 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 255 of file ApiPageSet.php.

ApiPageSet::getDB ( ) [protected]

Get the database connection (read-only)

Returns:
DatabaseBase

Reimplemented from ApiBase.

Definition at line 1070 of file ApiPageSet.php.

Get an array of all available generators.

Returns:
array

Definition at line 1128 of file ApiPageSet.php.

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

Returns:
int

Definition at line 356 of file ApiPageSet.php.

Title objects that were found in the database.

Returns:
Title[] Array page_id (int) => Title (obj)

Definition at line 348 of file ApiPageSet.php.

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

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

Definition at line 488 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:
ApiResult$result
bool$iwUrl
Returns:
array Array of raw_prefixed_title (string) => interwiki_prefix (string)
Since:
1.21

Definition at line 500 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:
string[] Array of strings (not Title objects)

Definition at line 374 of file ApiPageSet.php.

ApiPageSet::getInvalidTitlesAndRevisions ( invalidChecks = array( 'invalidTitles', 'special', 'missingIds', 'missingRevIds', 'missingTitles', 'interwikiTitles' ))

Get an array of invalid/special/missing titles.

Parameters:
array$invalidChecksList of types of invalid titles to include. Recognized values are:
Returns:
array Array suitable for inclusion in the response
Since:
1.23

Definition at line 534 of file ApiPageSet.php.

Page IDs that were not found in the database.

Returns:
array Array of page IDs

Definition at line 382 of file ApiPageSet.php.

Revision IDs that were not found in the database.

Returns:
array Array of revision IDs

Definition at line 572 of file ApiPageSet.php.

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

Parameters:
ApiResult$result
Returns:
array Array of revision IDs
Since:
1.21

Definition at line 582 of file ApiPageSet.php.

Title objects that were NOT found in the database.

The array's index will be negative for each item

Returns:
Title[]

Definition at line 365 of file ApiPageSet.php.

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

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

Definition at line 426 of file ApiPageSet.php.

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

Parameters:
ApiResult$result
Returns:
array Array of raw_prefixed_title (string) => prefixed_title (string)
Since:
1.21

Definition at line 437 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 Array of field names

Definition at line 297 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 1150 of file ApiPageSet.php.

static ApiPageSet::getPositiveIntegers ( array) [static, private]

Returns the input array of integers with all values < 0 removed.

Parameters:
array$array
Returns:
array

Definition at line 1080 of file ApiPageSet.php.

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 914 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:
Title[]

Definition at line 391 of file ApiPageSet.php.

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

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

Definition at line 402 of file ApiPageSet.php.

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

Returns:
int Number of revisions.

Definition at line 608 of file ApiPageSet.php.

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

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

Definition at line 564 of file ApiPageSet.php.

Get the list of titles with negative namespace.

Returns:
Title[]

Definition at line 600 of file ApiPageSet.php.

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

Returns:
int

Definition at line 340 of file ApiPageSet.php.

All Title objects provided.

Returns:
Title[]

Definition at line 332 of file ApiPageSet.php.

ApiPageSet::initFromPageIds ( pageids) [private]

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

Parameters:
array$pageidsArray of page IDs

Definition at line 727 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:
ResultWrapper$resDB Query result
array$remainingArray of 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 767 of file ApiPageSet.php.

ApiPageSet::initFromRevIDs ( revids) [private]

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

Parameters:
array$revidsArray of revision IDs

Definition at line 834 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$titlesArray of Title objects or strings

Definition at line 700 of file ApiPageSet.php.

Check whether this PageSet is resolving redirects.

Returns:
bool

Definition at line 243 of file ApiPageSet.php.

Populate this PageSet from a list of page IDs.

Parameters:
array$pageIDsArray of page IDs

Definition at line 626 of file ApiPageSet.php.

ApiPageSet::populateFromQueryResult ( db,
queryResult 
)

Populate this PageSet from a rowset returned from the database.

Parameters:
DatabaseBase$db
ResultWrapper$queryResultQuery result object

Definition at line 637 of file ApiPageSet.php.

Populate this PageSet from a list of revision IDs.

Parameters:
array$revIDsArray of revision IDs

Definition at line 647 of file ApiPageSet.php.

Populate this PageSet from a list of Titles.

Parameters:
array$titlesArray of Title objects

Definition at line 616 of file ApiPageSet.php.

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

Parameters:
stdClass$rowResult row

Definition at line 657 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$titlesArray of Title objects or strings
Returns:
LinkBatch

Definition at line 992 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 277 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 875 of file ApiPageSet.php.


Member Data Documentation

ApiPageSet::$generators = null [static, private]

Definition at line 1122 of file ApiPageSet.php.

ApiPageSet::$mAllowGenerator [private]

Definition at line 52 of file ApiPageSet.php.

ApiPageSet::$mAllPages = array() [private]

Definition at line 54 of file ApiPageSet.php.

ApiPageSet::$mCacheMode = 'public' [private]

Definition at line 69 of file ApiPageSet.php.

ApiPageSet::$mConvertedTitles = array() [private]

Definition at line 65 of file ApiPageSet.php.

ApiPageSet::$mConvertTitles [private]

Definition at line 51 of file ApiPageSet.php.

ApiPageSet::$mDbSource [private]

Definition at line 48 of file ApiPageSet.php.

int ApiPageSet::$mDefaultNamespace = NS_MAIN [private]

*

Definition at line 71 of file ApiPageSet.php.

ApiPageSet::$mFakePageId = -1 [private]

Definition at line 68 of file ApiPageSet.php.

ApiPageSet::$mGoodRevIDs = array() [private]

Definition at line 66 of file ApiPageSet.php.

ApiPageSet::$mGoodTitles = array() [private]

Definition at line 56 of file ApiPageSet.php.

ApiPageSet::$mInterwikiTitles = array() [private]

Definition at line 63 of file ApiPageSet.php.

ApiPageSet::$mInvalidTitles = array() [private]

Definition at line 58 of file ApiPageSet.php.

ApiPageSet::$mMissingPageIDs = array() [private]

Definition at line 59 of file ApiPageSet.php.

ApiPageSet::$mMissingRevIDs = array() [private]

Definition at line 67 of file ApiPageSet.php.

ApiPageSet::$mMissingTitles = array() [private]

Definition at line 57 of file ApiPageSet.php.

ApiPageSet::$mNormalizedTitles = array() [private]

Definition at line 62 of file ApiPageSet.php.

ApiPageSet::$mParams [private]

Definition at line 49 of file ApiPageSet.php.

Title [] ApiPageSet::$mPendingRedirectIDs = array() [private]

*

Definition at line 64 of file ApiPageSet.php.

ApiPageSet::$mRedirectTitles = array() [private]

Definition at line 60 of file ApiPageSet.php.

ApiPageSet::$mRequestedPageFields = array() [private]

Definition at line 70 of file ApiPageSet.php.

ApiPageSet::$mResolveRedirects [private]

Definition at line 50 of file ApiPageSet.php.

ApiPageSet::$mSpecialTitles = array() [private]

Definition at line 61 of file ApiPageSet.php.

ApiPageSet::$mTitles = array() [private]

Definition at line 55 of file ApiPageSet.php.

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

Since:
1.21

Definition at line 46 of file ApiPageSet.php.


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