MediaWiki  REL1_19
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 ($query, $resolveRedirects=false, $convertTitles=false)
 Constructor.
 execute ()
 Populate the PageSet from the request parameters.
 finishPageSetGeneration ()
 Resolve redirects, if applicable.
 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.
 getAllTitlesByNamespace ()
 Returns an array [ns][dbkey] => page_id for all requested titles.
 getConvertedTitles ()
 Get a list of title conversions - maps a title to its converted version.
 getCustomField ($fieldName)
 Get the value of a custom field previously requested through requestField()
 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.
 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.
 getMissingTitles ()
 Title objects that were NOT found in the database.
 getNormalizedTitles ()
 Get a list of title normalizations - maps a title to its normalized version.
 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 ()
 getRedirectTitles ()
 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.
 getVersion ()
 Returns a string that identifies the version of the extending class.
 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

 $mConvertedTitles
 $mGoodTitles
 $mInterwikiTitles
 $mInvalidTitles
 $mMissingRevIDs
 $mMissingTitles
 $mPendingRedirectIDs
 $mRedirectTitles
 $mSpecialTitles

Private Member Functions

 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

 $mAllPages
 $mConvertTitles
 $mFakePageId
 $mGoodRevIDs
 $mMissingPageIDs
 $mNormalizedTitles
 $mRequestedPageFields
 $mResolveRedirects
 $mTitles

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.

Definition at line 40 of file ApiPageSet.php.


Constructor & Destructor Documentation

ApiPageSet::__construct ( query,
resolveRedirects = false,
convertTitles = false 
)

Constructor.

Parameters:
$queryApiQueryBase
$resolveRedirectsbool Whether redirects should be resolved
$convertTitlesbool

Reimplemented from ApiBase.

Definition at line 59 of file ApiPageSet.php.


Member Function Documentation

Populate the PageSet from the request parameters.

Reimplemented from ApiBase.

Definition at line 279 of file ApiPageSet.php.

References ApiBase\dieUsage(), ApiBase\extractRequestParams(), initFromPageIds(), initFromRevIDs(), initFromTitles(), ApiBase\profileIn(), ApiBase\profileOut(), and ApiBase\setWarning().

Here is the call graph for this function:

Resolve redirects, if applicable.

Definition at line 390 of file ApiPageSet.php.

References ApiBase\profileIn(), ApiBase\profileOut(), and resolvePendingRedirects().

Here is the call graph for this function:

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.

Returns:
array or false

Reimplemented from ApiBase.

Definition at line 741 of file ApiPageSet.php.

References 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

Returns:
array

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

ApiPageSet::getCustomField ( fieldName)

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

Parameters:
$fieldNamestring Field name
Returns:
mixed Field value

Definition at line 110 of file ApiPageSet.php.

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

Returns:
int

Definition at line 178 of file ApiPageSet.php.

Title objects that were found in the database.

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

Definition at line 170 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 240 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 196 of file ApiPageSet.php.

Page IDs that were not found in the database.

Returns:
array of page IDs

Definition at line 204 of file ApiPageSet.php.

Revision IDs that were not found in the database.

Returns:
array of revision IDs

Definition at line 256 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 187 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 222 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 120 of file ApiPageSet.php.

Referenced by initFromPageIds(), initFromTitles(), and resolvePendingRedirects().

Here is the caller graph for this function:

Returns an array of parameter descriptions.

Don't call this functon directly: use getFinalParamDescription() to allow hooks to modify descriptions as needed.

Returns:
array or false

Reimplemented from ApiBase.

Definition at line 757 of file ApiPageSet.php.

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

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

Parameters:
$arrayarray
Returns:
array

Definition at line 728 of file ApiPageSet.php.

Referenced by initFromPageIds(), and initFromRevIDs().

Here is the caller graph for this function:

Returns:
array

Reimplemented from ApiQueryBase.

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

References $lb, $page, $res, $title, WikiPage\factory(), ApiQueryBase\getDB(), Title\makeTitle(), ApiBase\profileDBIn(), and ApiBase\profileDBOut().

Referenced by resolvePendingRedirects().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Returns:
array prefixed_title (string) => Title object

Definition at line 213 of file ApiPageSet.php.

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

Returns:
int

Definition at line 272 of file ApiPageSet.php.

References getRevisionIDs().

Here is the call graph for this function:

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

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

Definition at line 248 of file ApiPageSet.php.

Referenced by getRevisionCount().

Here is the caller graph for this function:

Get the list of titles with negative namespace.

Returns:
array Title

Definition at line 264 of file ApiPageSet.php.

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

Returns:
int

Definition at line 162 of file ApiPageSet.php.

All Title objects provided.

Returns:
array of Title objects

Definition at line 154 of file ApiPageSet.php.

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

Returns:
string

Reimplemented from ApiBase.

Definition at line 772 of file ApiPageSet.php.

ApiPageSet::initFromPageIds ( pageids) [private]

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

Parameters:
$pageidsarray of page IDs

Definition at line 439 of file ApiPageSet.php.

References $res, ApiQueryBase\getDB(), getPageTableFields(), getPositiveIntegers(), initFromQueryResult(), ApiBase\profileDBIn(), ApiBase\profileDBOut(), and resolvePendingRedirects().

Referenced by execute(), initFromRevIDs(), and populateFromPageIDs().

Here is the call graph for this function:

Here is the caller graph for this function:

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
$remainingarray of either pageID or ns/title elements (optional). If given, any missing items will go to $mMissingPageIDs and $mMissingTitles
$processTitlesbool 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 479 of file ApiPageSet.php.

References $res, $title, ApiBase\dieDebug(), Title\makeTitle(), and processDbRow().

Referenced by initFromPageIds(), initFromTitles(), populateFromQueryResult(), and resolvePendingRedirects().

Here is the call graph for this function:

Here is the caller graph for this function:

ApiPageSet::initFromRevIDs ( revids) [private]

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

Parameters:
$revidsarray of revision IDs

Definition at line 531 of file ApiPageSet.php.

References ApiQueryBase\$fields, $res, ApiQueryBase\$tables, ApiQueryBase\$where, ApiQueryBase\getDB(), getPositiveIntegers(), initFromPageIds(), ApiBase\profileDBIn(), and ApiBase\profileDBOut().

Referenced by execute(), and populateFromRevisionIDs().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
$titlesarray of Title objects or strings

Definition at line 412 of file ApiPageSet.php.

References $res, ApiQueryBase\getDB(), getPageTableFields(), initFromQueryResult(), processTitlesArray(), ApiBase\profileDBIn(), ApiBase\profileDBOut(), and resolvePendingRedirects().

Referenced by execute(), and populateFromTitles().

Here is the call graph for this function:

Here is the caller graph for this function:

Check whether this PageSet is resolving redirects.

Returns:
bool

Definition at line 91 of file ApiPageSet.php.

Populate this PageSet from a list of page IDs.

Parameters:
$pageIDsarray of page IDs

Definition at line 337 of file ApiPageSet.php.

References initFromPageIds(), ApiBase\profileIn(), and ApiBase\profileOut().

Here is the call graph for this function:

ApiPageSet::populateFromQueryResult ( db,
queryResult 
)

Populate this PageSet from a rowset returned from the database.

Parameters:
$dbDatabase object
$queryResultResultWrapper Query result object

Definition at line 348 of file ApiPageSet.php.

References initFromQueryResult(), ApiBase\profileIn(), and ApiBase\profileOut().

Here is the call graph for this function:

Populate this PageSet from a list of revision IDs.

Parameters:
$revIDsarray of revision IDs

Definition at line 358 of file ApiPageSet.php.

References initFromRevIDs(), ApiBase\profileIn(), and ApiBase\profileOut().

Here is the call graph for this function:

Populate this PageSet from a list of Titles.

Parameters:
$titlesarray of Title objects

Definition at line 327 of file ApiPageSet.php.

References initFromTitles(), ApiBase\profileIn(), and ApiBase\profileOut().

Here is the call graph for this function:

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

Parameters:
$rowResult row

Definition at line 368 of file ApiPageSet.php.

References $title, and Title\makeTitle().

Referenced by initFromQueryResult().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters:
$titlesarray of Title objects or strings
Returns:
LinkBatch

Definition at line 666 of file ApiPageSet.php.

References $title, $wgContLang, and Title\newFromText().

Referenced by initFromTitles().

Here is the call graph for this function:

Here is the caller graph for this function:

ApiPageSet::requestField ( fieldName)

Request an additional field from the page table.

Must be called before execute()

Parameters:
$fieldNamestring Field name

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

References $res, ApiQueryBase\getDB(), getPageTableFields(), getRedirectTargets(), initFromQueryResult(), ApiBase\profileDBIn(), and ApiBase\profileDBOut().

Referenced by finishPageSetGeneration(), initFromPageIds(), and initFromTitles().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

ApiPageSet::$mAllPages [private]

Definition at line 42 of file ApiPageSet.php.

ApiPageSet::$mConvertedTitles

Definition at line 47 of file ApiPageSet.php.

ApiPageSet::$mConvertTitles [private]

Definition at line 47 of file ApiPageSet.php.

ApiPageSet::$mFakePageId [private]

Definition at line 49 of file ApiPageSet.php.

ApiPageSet::$mGoodRevIDs [private]

Definition at line 48 of file ApiPageSet.php.

ApiPageSet::$mGoodTitles

Definition at line 43 of file ApiPageSet.php.

ApiPageSet::$mInterwikiTitles

Definition at line 45 of file ApiPageSet.php.

ApiPageSet::$mInvalidTitles

Definition at line 43 of file ApiPageSet.php.

ApiPageSet::$mMissingPageIDs [private]

Definition at line 44 of file ApiPageSet.php.

ApiPageSet::$mMissingRevIDs

Definition at line 48 of file ApiPageSet.php.

ApiPageSet::$mMissingTitles

Definition at line 43 of file ApiPageSet.php.

ApiPageSet::$mNormalizedTitles [private]

Definition at line 45 of file ApiPageSet.php.

ApiPageSet::$mPendingRedirectIDs

Definition at line 46 of file ApiPageSet.php.

ApiPageSet::$mRedirectTitles

Definition at line 44 of file ApiPageSet.php.

ApiPageSet::$mRequestedPageFields [private]

Definition at line 51 of file ApiPageSet.php.

ApiPageSet::$mResolveRedirects [private]

Definition at line 46 of file ApiPageSet.php.

ApiPageSet::$mSpecialTitles

Definition at line 44 of file ApiPageSet.php.

ApiPageSet::$mTitles [private]

Definition at line 43 of file ApiPageSet.php.


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