MediaWiki  1.23.2
ApiPageSet Class Reference

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

Inheritance diagram for ApiPageSet:
Collaboration diagram for ApiPageSet:

Public Member Functions

 __construct (ApiBase $dbSource, $flags=0, $defaultNamespace=NS_MAIN)
 Constructor. More...
 
 execute ()
 Populate the PageSet from the request parameters. More...
 
 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. More...
 
 finishPageSetGeneration ()
 Do not use, does nothing, will be removed. More...
 
 getAllowedParams ( $flags=0)
 
 getAllTitlesByNamespace ()
 Returns an array [ns][dbkey] => page_id for all requested titles. More...
 
 getCacheMode ( $params=null)
 Get the cache mode for the data generated by this module. More...
 
 getConvertedTitles ()
 Get a list of title conversions - maps a title to its converted version. More...
 
 getConvertedTitlesAsResult ( $result=null)
 Get a list of title conversions - maps a title to its converted version as a result array. More...
 
 getCustomField ( $fieldName)
 Get the value of a custom field previously requested through requestField() More...
 
 getDataSource ()
 Return the parameter name that is the source of data for this PageSet. More...
 
 getGoodTitleCount ()
 Returns the number of found unique pages (not revisions) in the set. More...
 
 getGoodTitles ()
 Title objects that were found in the database. More...
 
 getInterwikiTitles ()
 Get a list of interwiki titles - maps a title to its interwiki prefix. More...
 
 getInterwikiTitlesAsResult ( $result=null, $iwUrl=false)
 Get a list of interwiki titles - maps a title to its interwiki prefix as result. More...
 
 getInvalidTitles ()
 Titles that were deemed invalid by Title::newFromText() The array's index will be unique and negative for each item. More...
 
 getInvalidTitlesAndRevisions ( $invalidChecks=array( 'invalidTitles', 'special', 'missingIds', 'missingRevIds', 'missingTitles', 'interwikiTitles'))
 Get an array of invalid/special/missing titles. More...
 
 getMissingPageIDs ()
 Page IDs that were not found in the database. More...
 
 getMissingRevisionIDs ()
 Revision IDs that were not found in the database. More...
 
 getMissingRevisionIDsAsResult ( $result=null)
 Revision IDs that were not found in the database as result array. More...
 
 getMissingTitles ()
 Title objects that were NOT found in the database. More...
 
 getNormalizedTitles ()
 Get a list of title normalizations - maps a title to its normalized version. More...
 
 getNormalizedTitlesAsResult ( $result=null)
 Get a list of title normalizations - maps a title to its normalized version in the form of result array. More...
 
 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. More...
 
 getParamDescription ()
 Returns an array of parameter descriptions. More...
 
 getPossibleErrors ()
 Returns a list of all possible errors returned by the module. More...
 
 getRedirectTitles ()
 Get a list of redirect resolutions - maps a title to its redirect target, as an array of output-ready arrays. More...
 
 getRedirectTitlesAsResult ( $result=null)
 Get a list of redirect resolutions - maps a title to its redirect target. More...
 
 getRevisionCount ()
 Returns the number of revisions (requested with revids= parameter). More...
 
 getRevisionIDs ()
 Get the list of revision IDs (requested with the revids= parameter) More...
 
 getSpecialTitles ()
 Get the list of titles with negative namespace. More...
 
 getTitleCount ()
 Returns the number of unique pages (not revisions) in the set. More...
 
 getTitles ()
 All Title objects provided. More...
 
 isResolvingRedirects ()
 Check whether this PageSet is resolving redirects. More...
 
 populateFromPageIDs ( $pageIDs)
 Populate this PageSet from a list of page IDs. More...
 
 populateFromQueryResult ( $db, $queryResult)
 Populate this PageSet from a rowset returned from the database. More...
 
 populateFromRevisionIDs ( $revIDs)
 Populate this PageSet from a list of revision IDs. More...
 
 populateFromTitles ( $titles)
 Populate this PageSet from a list of Titles. More...
 
 processDbRow ( $row)
 Extract all requested fields from the row received from the database. More...
 
 requestField ( $fieldName)
 Request an additional field from the page table. More...
 
- Public Member Functions inherited from ApiBase
 __construct ( $mainModule, $moduleName, $modulePrefix='')
 Constructor. More...
 
 createContext ()
 Create a new RequestContext object to use e.g. More...
 
 dieReadOnly ()
 Helper function for readonly errors. More...
 
 dieStatus ( $status)
 Throw a UsageException based on the errors in the Status object. More...
 
 dieUsage ( $description, $errorCode, $httpRespCode=0, $extradata=null)
 Throw a UsageException, which will (if uncaught) call the main module's error handler and die with an error message. More...
 
 dieUsageMsg ( $error)
 Output the error message related to a certain array. More...
 
 dieUsageMsgOrDebug ( $error)
 Will only set a warning instead of failing if the global $wgDebugAPI is set to true. More...
 
 encodeParamName ( $paramName)
 This method mangles parameter name based on the prefix supplied to the constructor. More...
 
 extractRequestParams ( $parseLimit=true)
 Using getAllowedParams(), this function makes an array of the values provided by the user, with key being the name of the variable, and value - validated value from user or default. More...
 
 getCustomPrinter ()
 If the module may only be used with a certain format module, it should override this method to return an instance of that formatter. More...
 
 getErrorFromStatus ( $status)
 Get error (as code, string) from a Status object. More...
 
 getFinalDescription ()
 Get final module description, after hooks have had a chance to tweak it as needed. More...
 
 getFinalParamDescription ()
 Get final parameter descriptions, after hooks have had a chance to tweak it as needed. More...
 
 getFinalParams ( $flags=0)
 Get final list of parameters, after hooks have had a chance to tweak it as needed. More...
 
 getFinalPossibleErrors ()
 Get final list of possible errors, after hooks have had a chance to tweak it as needed. More...
 
 getFinalResultProperties ()
 Get final possible result properties, after hooks have had a chance to tweak it as needed. More...
 
 getHelpUrls ()
 
 getMain ()
 Get the main module. More...
 
 getModuleManager ()
 Get the module manager, or null if this module has no sub-modules. More...
 
 getModuleName ()
 Get the name of the module being executed by this instance. More...
 
 getModulePrefix ()
 Get parameter prefix (usually two letters or an empty string). More...
 
 getModuleProfileName ( $db=false)
 Get the name of the module as shown in the profiler log. More...
 
 getProfileDBTime ()
 Total time the module used the database. More...
 
 getProfileTime ()
 Total time the module was executed. More...
 
 getRequireAtLeastOneParameterErrorMessages ( $params)
 Generates the possible errors requireAtLeastOneParameter() can die with. More...
 
 getRequireMaxOneParameterErrorMessages ( $params)
 Generates the possible error requireMaxOneParameter() can die with. More...
 
 getRequireOnlyOneParameterErrorMessages ( $params)
 Generates the possible errors requireOnlyOneParameter() can die with. More...
 
 getResult ()
 Get the result object. More...
 
 getResultData ()
 Get the result data array (read-only) More...
 
 getTitleOrPageId ( $params, $load=false)
 
 getTitleOrPageIdErrorMessage ()
 
 getTokenSalt ()
 Returns the token salt if there is one, '' if the module doesn't require a salt, else false if the module doesn't need a token You have also to override needsToken() Value is passed to User::getEditToken. More...
 
 getVersion ()
 Returns a string that identifies the version of the extending class. More...
 
 getWatchlistUser ( $params)
 Gets the user for whom to get the watchlist. More...
 
 isMain ()
 Returns true if this module is the main module ($this === $this->mMainModule), false otherwise. More...
 
 isReadMode ()
 Indicates whether this module requires read rights. More...
 
 isWriteMode ()
 Indicates whether this module requires write mode. More...
 
 makeHelpMsg ()
 Generates help message for this module, or false if there is no description. More...
 
 makeHelpMsgParameters ()
 Generates the parameter descriptions for this module, to be displayed in the module's help. More...
 
 mustBePosted ()
 Indicates whether this module must be called with a POST request. More...
 
 needsToken ()
 Returns whether this module requires a token to execute It is used to show possible errors in action=paraminfo see bug 25248. More...
 
 parseErrors ( $errors)
 Parses a list of errors into a standardised format. More...
 
 parseMsg ( $error)
 Return the error message related to a certain array. More...
 
 profileDBIn ()
 Start module profiling. More...
 
 profileDBOut ()
 End database profiling. More...
 
 profileIn ()
 Start module profiling. More...
 
 profileOut ()
 End module profiling. More...
 
 requireAtLeastOneParameter ( $params)
 Die if none of a certain set of parameters is set and not false. More...
 
 requireMaxOneParameter ( $params)
 Die if more than one of a certain set of parameters is set and not false. More...
 
 requireOnlyOneParameter ( $params)
 Die if none or more than one of a certain set of parameters is set and not false. More...
 
 safeProfileOut ()
 When modules crash, sometimes it is needed to do a profileOut() regardless of the profiling state the module was in. More...
 
 setWarning ( $warning)
 Set warning section for this module. More...
 
 shouldCheckMaxlag ()
 Indicates if this module needs maxlag to be checked. More...
 
 validateLimit ( $paramName, &$value, $min, $max, $botMax=null, $enforceLimits=false)
 Validate the value against the minimum and user/bot maximum limits. More...
 
 validateTimestamp ( $value, $encParamName)
 Validate and normalize of parameters of type 'timestamp'. More...
 
- Public Member Functions inherited from ContextSource
 canUseWikiPage ()
 Check whether a WikiPage object can be get with getWikiPage(). More...
 
 exportSession ()
 Export the resolved user IP, HTTP headers, user ID, and session ID. More...
 
 getConfig ()
 Get the Config object. More...
 
 getContext ()
 Get the RequestContext object. More...
 
 getLang ()
 Get the Language object. More...
 
 getLanguage ()
 Get the Language object. More...
 
 getOutput ()
 Get the OutputPage object. More...
 
 getRequest ()
 Get the WebRequest object. More...
 
 getSkin ()
 Get the Skin object. More...
 
 getTitle ()
 Get the Title object. More...
 
 getUser ()
 Get the User object. More...
 
 getWikiPage ()
 Get the WikiPage object. More...
 
 msg ()
 Get a Message object with context set Parameters are the same as wfMessage() More...
 
 setContext (IContextSource $context)
 Set the IContextSource object. More...
 

Public Attributes

const DISABLE_GENERATORS = 1
 Constructor flag: The new instance of ApiPageSet will ignore the 'generator=' parameter. More...
 
- Public Attributes inherited from ApiBase
 $mDBTime = 0
 
 $mModuleName
 
 $mModulePrefix
 
 $mModuleTime = 0
 
const GET_VALUES_FOR_HELP = 1
 getAllowedParams() flag: When set, the result could take longer to generate, but should be more thorough. More...
 
const LIMIT_BIG1 = 500
 
const LIMIT_BIG2 = 5000
 
const LIMIT_SML1 = 50
 
const LIMIT_SML2 = 500
 
const PARAM_ALLOW_DUPLICATES = 6
 
const PARAM_DEPRECATED = 7
 
const PARAM_DFLT = 0
 
const PARAM_ISMULTI = 1
 
const PARAM_MAX = 3
 
const PARAM_MAX2 = 4
 
const PARAM_MIN = 5
 
const PARAM_RANGE_ENFORCE = 9
 
const PARAM_REQUIRED = 8
 
const PARAM_TYPE = 2
 
const PROP_LIST = 'LIST'
 
const PROP_NULLABLE = 1
 
const PROP_ROOT = 'ROOT'
 
const PROP_TYPE = 0
 

Protected Member Functions

 getDB ()
 Get the database connection (read-only) More...
 
- Protected Member Functions inherited from ApiBase
 dieContinueUsageIf ( $condition)
 Die with the $prefix. More...
 
 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. More...
 
 getDescription ()
 Returns the description string for this module. More...
 
 getExamples ()
 Returns usage examples for this module. More...
 
 getParameter ( $paramName, $parseLimit=true)
 Get a value for the given parameter. More...
 
 getParameterFromSettings ( $paramName, $paramSettings, $parseLimit)
 Using the settings determine the value for the given parameter. More...
 
 getResultProperties ()
 Returns possible properties in the result, grouped by the value of the prop parameter that shows them. More...
 
 getWatchlistValue ( $watchlist, $titleObj, $userOption=null)
 Return true if we're to watch the page, false if not, null if no change. More...
 
 makeHelpArrayToString ( $prefix, $title, $input)
 
 parseMultiValue ( $valueName, $value, $allowMultiple, $allowedValues)
 Return an array of values that were given in a 'a|b|c' notation, after it optionally validates them against the list allowed values. More...
 
 setWatch ( $watch, $titleObj, $userOption=null)
 Set a watch (or unwatch) based the based on a watchlist parameter. More...
 

Private Member Functions

 executeInternal ( $isDryRun)
 Populate the PageSet from the request parameters. More...
 
 getGenerators ()
 Get an array of all available generators. More...
 
 getRedirectTargets ()
 Get the targets of the pending redirects from the database. More...
 
 initFromPageIds ( $pageids)
 Does the same as initFromTitles(), but is based on page IDs instead. More...
 
 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. More...
 
 initFromRevIDs ( $revids)
 Does the same as initFromTitles(), but is based on revision IDs instead. More...
 
 initFromTitles ( $titles)
 This method populates internal variables with page information based on the given array of title strings. More...
 
 processTitlesArray ( $titles)
 Given an array of title strings, convert them into Title objects. More...
 
 resolvePendingRedirects ()
 Resolve any redirects in the result if redirect resolution was requested. More...
 

Static Private Member Functions

static addValues (array &$result, $values, $flag=null, $name=null)
 Add all items from $values into the result. More...
 
static getPositiveIntegers ( $array)
 Returns the input array of integers with all values < 0 removed. More...
 

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
 

Additional Inherited Members

- Static Public Member Functions inherited from ApiBase
static debugPrint ( $value, $name='unknown', $backtrace=false)
 Debugging function that prints a value and an optional backtrace. More...
 
static truncateArray (&$arr, $limit)
 Truncate an array to a certain length. More...
 
- Static Public Attributes inherited from ApiBase
static $messageMap
 Array that maps message keys to error messages. More...
 
- Static Protected Member Functions inherited from ApiBase
static addTokenProperties (&$props, $tokenFunctions)
 Add token properties to the array used by getResultProperties, based on a token functions mapping. More...
 
static dieDebug ( $method, $message)
 Internal code errors should be reported with this method. More...
 

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

◆ __construct()

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 107 of file ApiPageSet.php.

References $flags, DISABLE_GENERATORS, ApiBase\extractRequestParams(), ApiBase\getMain(), ApiBase\getModuleName(), ApiBase\profileIn(), and ApiBase\profileOut().

Member Function Documentation

◆ addValues()

static ApiPageSet::addValues ( array $result,
  $values,
  $flag = null,
  $name = null 
)
staticprivate

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 82 of file ApiPageSet.php.

References $name, ApiQueryBase\addTitleInfo(), array(), and as.

Referenced by getInvalidTitlesAndRevisions().

◆ execute()

ApiPageSet::execute ( )

Populate the PageSet from the request parameters.

Reimplemented from ApiBase.

Definition at line 131 of file ApiPageSet.php.

References executeInternal().

◆ executeDryRun()

ApiPageSet::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.

Definition at line 124 of file ApiPageSet.php.

References executeInternal().

◆ executeInternal()

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 140 of file ApiPageSet.php.

References $mDbSource, array(), as, ApiBase\dieUsage(), DISABLE_GENERATORS, ApiBase\getMain(), initFromPageIds(), initFromRevIDs(), initFromTitles(), ApiBase\profileIn(), ApiBase\profileOut(), resolvePendingRedirects(), ApiBase\setWarning(), and wfRunHooks().

Referenced by execute(), and executeDryRun().

◆ finishPageSetGeneration()

ApiPageSet::finishPageSetGeneration ( )

Do not use, does nothing, will be removed.

Deprecated:
since 1.21

Definition at line 683 of file ApiPageSet.php.

References wfDeprecated().

◆ getAllowedParams()

ApiPageSet::getAllowedParams (   $flags = 0)

◆ getAllTitlesByNamespace()

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

Returns
array

Definition at line 327 of file ApiPageSet.php.

References $mAllPages.

◆ getCacheMode()

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 982 of file ApiPageSet.php.

References $mCacheMode.

◆ getConvertedTitles()

ApiPageSet::getConvertedTitles ( )

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 460 of file ApiPageSet.php.

References $mConvertedTitles.

Referenced by getConvertedTitlesAsResult().

◆ getConvertedTitlesAsResult()

ApiPageSet::getConvertedTitlesAsResult (   $result = null)

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 471 of file ApiPageSet.php.

References array(), as, and getConvertedTitles().

◆ getCustomField()

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 290 of file ApiPageSet.php.

◆ getDataSource()

ApiPageSet::getDataSource ( )

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 258 of file ApiPageSet.php.

◆ getDB()

ApiPageSet::getDB ( )
protected

Get the database connection (read-only)

Returns
DatabaseBase

Reimplemented from ApiBase.

Definition at line 1073 of file ApiPageSet.php.

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

◆ getGenerators()

ApiPageSet::getGenerators ( )
private

Get an array of all available generators.

Returns
array

Definition at line 1131 of file ApiPageSet.php.

References $generators, $mDbSource, $name, $query, array(), as, and ApiBase\getMain().

Referenced by getAllowedParams().

◆ getGoodTitleCount()

ApiPageSet::getGoodTitleCount ( )

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

Returns
int

Definition at line 359 of file ApiPageSet.php.

◆ getGoodTitles()

ApiPageSet::getGoodTitles ( )

Title objects that were found in the database.

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

Definition at line 351 of file ApiPageSet.php.

References $mGoodTitles.

◆ getInterwikiTitles()

ApiPageSet::getInterwikiTitles ( )

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 491 of file ApiPageSet.php.

References $mInterwikiTitles.

Referenced by getInterwikiTitlesAsResult().

◆ getInterwikiTitlesAsResult()

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 503 of file ApiPageSet.php.

References $title, array(), as, getInterwikiTitles(), Title\newFromText(), and PROTO_CURRENT.

Referenced by getInvalidTitlesAndRevisions().

◆ getInvalidTitles()

ApiPageSet::getInvalidTitles ( )

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 377 of file ApiPageSet.php.

References $mInvalidTitles.

Referenced by getInvalidTitlesAndRevisions().

◆ getInvalidTitlesAndRevisions()

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

Get an array of invalid/special/missing titles.

Parameters
$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 537 of file ApiPageSet.php.

References addValues(), array(), getInterwikiTitlesAsResult(), getInvalidTitles(), getMissingPageIDs(), getMissingRevisionIDs(), getMissingTitles(), and getSpecialTitles().

◆ getMissingPageIDs()

ApiPageSet::getMissingPageIDs ( )

Page IDs that were not found in the database.

Returns
array of page IDs

Definition at line 385 of file ApiPageSet.php.

References $mMissingPageIDs.

Referenced by getInvalidTitlesAndRevisions().

◆ getMissingRevisionIDs()

ApiPageSet::getMissingRevisionIDs ( )

Revision IDs that were not found in the database.

Returns
array of revision IDs

Definition at line 575 of file ApiPageSet.php.

References $mMissingRevIDs.

Referenced by getInvalidTitlesAndRevisions(), and getMissingRevisionIDsAsResult().

◆ getMissingRevisionIDsAsResult()

ApiPageSet::getMissingRevisionIDsAsResult (   $result = null)

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 585 of file ApiPageSet.php.

References array(), as, and getMissingRevisionIDs().

◆ getMissingTitles()

ApiPageSet::getMissingTitles ( )

Title objects that were NOT found in the database.

The array's index will be negative for each item

Returns
Title[]

Definition at line 368 of file ApiPageSet.php.

References $mMissingTitles.

Referenced by getInvalidTitlesAndRevisions().

◆ getNormalizedTitles()

ApiPageSet::getNormalizedTitles ( )

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 429 of file ApiPageSet.php.

References $mNormalizedTitles.

Referenced by getNormalizedTitlesAsResult().

◆ getNormalizedTitlesAsResult()

ApiPageSet::getNormalizedTitlesAsResult (   $result = null)

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 440 of file ApiPageSet.php.

References array(), as, and getNormalizedTitles().

◆ getPageTableFields()

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.

Returns
array of field names

Definition at line 300 of file ApiPageSet.php.

References array().

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

◆ getParamDescription()

ApiPageSet::getParamDescription ( )

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 1153 of file ApiPageSet.php.

References array().

◆ getPositiveIntegers()

static ApiPageSet::getPositiveIntegers (   $array)
staticprivate

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

Parameters
$arrayarray
Returns
array

Definition at line 1083 of file ApiPageSet.php.

References as.

Referenced by initFromPageIds(), and initFromRevIDs().

◆ getPossibleErrors()

ApiPageSet::getPossibleErrors ( )

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 1172 of file ApiPageSet.php.

References array().

◆ getRedirectTargets()

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.

Returns
LinkBatch

Definition at line 917 of file ApiPageSet.php.

References $from, $lb, $res, $title, array(), as, WikiPage\factory(), getDB(), Title\makeTitle(), ApiBase\profileDBIn(), and ApiBase\profileDBOut().

Referenced by resolvePendingRedirects().

◆ getRedirectTitles()

ApiPageSet::getRedirectTitles ( )

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 394 of file ApiPageSet.php.

References $mRedirectTitles.

Referenced by getRedirectTitlesAsResult().

◆ getRedirectTitlesAsResult()

ApiPageSet::getRedirectTitlesAsResult (   $result = null)

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 405 of file ApiPageSet.php.

References array(), as, and getRedirectTitles().

◆ getRevisionCount()

ApiPageSet::getRevisionCount ( )

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

Returns
int Number of revisions.

Definition at line 611 of file ApiPageSet.php.

References getRevisionIDs().

◆ getRevisionIDs()

ApiPageSet::getRevisionIDs ( )

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

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

Definition at line 567 of file ApiPageSet.php.

References $mGoodRevIDs.

Referenced by getRevisionCount().

◆ getSpecialTitles()

ApiPageSet::getSpecialTitles ( )

Get the list of titles with negative namespace.

Returns
array Title

Definition at line 603 of file ApiPageSet.php.

References $mSpecialTitles.

Referenced by getInvalidTitlesAndRevisions().

◆ getTitleCount()

ApiPageSet::getTitleCount ( )

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

Returns
int

Definition at line 343 of file ApiPageSet.php.

◆ getTitles()

ApiPageSet::getTitles ( )

All Title objects provided.

Returns
Title[]

Definition at line 335 of file ApiPageSet.php.

References $mTitles.

◆ initFromPageIds()

ApiPageSet::initFromPageIds (   $pageids)
private

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

Parameters
array$pageidsof page IDs

Definition at line 730 of file ApiPageSet.php.

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

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

◆ initFromQueryResult()

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 770 of file ApiPageSet.php.

References $mFakePageId, $res, $title, array(), as, ApiBase\dieDebug(), MWNamespace\hasGenderDistinction(), Title\makeTitle(), processDbRow(), and GenderCache\singleton().

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

◆ initFromRevIDs()

ApiPageSet::initFromRevIDs (   $revids)
private

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

Parameters
array$revidsof revision IDs

Definition at line 837 of file ApiPageSet.php.

References $res, $tables, array(), as, getDB(), getPositiveIntegers(), initFromPageIds(), ApiBase\profileDBIn(), and ApiBase\profileDBOut().

Referenced by executeInternal(), and populateFromRevisionIDs().

◆ initFromTitles()

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 703 of file ApiPageSet.php.

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

Referenced by executeInternal(), and populateFromTitles().

◆ isResolvingRedirects()

ApiPageSet::isResolvingRedirects ( )

Check whether this PageSet is resolving redirects.

Returns
bool

Definition at line 246 of file ApiPageSet.php.

References $mResolveRedirects.

◆ populateFromPageIDs()

ApiPageSet::populateFromPageIDs (   $pageIDs)

Populate this PageSet from a list of page IDs.

Parameters
array$pageIDsof page IDs

Definition at line 629 of file ApiPageSet.php.

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

◆ populateFromQueryResult()

ApiPageSet::populateFromQueryResult (   $db,
  $queryResult 
)

Populate this PageSet from a rowset returned from the database.

Parameters
$dbDatabaseBase object
$queryResultResultWrapper Query result object

Definition at line 640 of file ApiPageSet.php.

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

◆ populateFromRevisionIDs()

ApiPageSet::populateFromRevisionIDs (   $revIDs)

Populate this PageSet from a list of revision IDs.

Parameters
array$revIDsof revision IDs

Definition at line 650 of file ApiPageSet.php.

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

◆ populateFromTitles()

ApiPageSet::populateFromTitles (   $titles)

Populate this PageSet from a list of Titles.

Parameters
array$titlesof Title objects

Definition at line 619 of file ApiPageSet.php.

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

◆ processDbRow()

ApiPageSet::processDbRow (   $row)

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

Parameters
stdClass$rowResult row

Definition at line 660 of file ApiPageSet.php.

References $title, as, and Title\newFromRow().

Referenced by initFromQueryResult().

◆ processTitlesArray()

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 995 of file ApiPageSet.php.

References $mFakePageId, $title, $titles, $wgContLang, array(), as, global, MWNamespace\hasGenderDistinction(), Title\newFromText(), and GenderCache\singleton().

Referenced by initFromTitles().

◆ requestField()

ApiPageSet::requestField (   $fieldName)

Request an additional field from the page table.

Must be called before execute()

Parameters
string$fieldNameField name

Definition at line 280 of file ApiPageSet.php.

◆ resolvePendingRedirects()

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 878 of file ApiPageSet.php.

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

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

Member Data Documentation

◆ $generators

ApiPageSet::$generators = null
staticprivate

Definition at line 1125 of file ApiPageSet.php.

Referenced by getGenerators().

◆ $mAllowGenerator

ApiPageSet::$mAllowGenerator
private

Definition at line 52 of file ApiPageSet.php.

◆ $mAllPages

ApiPageSet::$mAllPages = array()
private

Definition at line 54 of file ApiPageSet.php.

Referenced by getAllTitlesByNamespace().

◆ $mCacheMode

ApiPageSet::$mCacheMode = 'public'
private

Definition at line 69 of file ApiPageSet.php.

Referenced by getCacheMode().

◆ $mConvertedTitles

ApiPageSet::$mConvertedTitles = array()
private

Definition at line 65 of file ApiPageSet.php.

Referenced by getConvertedTitles().

◆ $mConvertTitles

ApiPageSet::$mConvertTitles
private

Definition at line 51 of file ApiPageSet.php.

◆ $mDbSource

ApiPageSet::$mDbSource
private

Definition at line 48 of file ApiPageSet.php.

Referenced by executeInternal(), and getGenerators().

◆ $mDefaultNamespace

int ApiPageSet::$mDefaultNamespace = NS_MAIN
private

Definition at line 73 of file ApiPageSet.php.

◆ $mFakePageId

ApiPageSet::$mFakePageId = -1
private

Definition at line 68 of file ApiPageSet.php.

Referenced by initFromQueryResult(), and processTitlesArray().

◆ $mGoodRevIDs

ApiPageSet::$mGoodRevIDs = array()
private

Definition at line 66 of file ApiPageSet.php.

Referenced by getRevisionIDs().

◆ $mGoodTitles

ApiPageSet::$mGoodTitles = array()
private

Definition at line 56 of file ApiPageSet.php.

Referenced by getGoodTitles().

◆ $mInterwikiTitles

ApiPageSet::$mInterwikiTitles = array()
private

Definition at line 63 of file ApiPageSet.php.

Referenced by getInterwikiTitles().

◆ $mInvalidTitles

ApiPageSet::$mInvalidTitles = array()
private

Definition at line 58 of file ApiPageSet.php.

Referenced by getInvalidTitles().

◆ $mMissingPageIDs

ApiPageSet::$mMissingPageIDs = array()
private

Definition at line 59 of file ApiPageSet.php.

Referenced by getMissingPageIDs().

◆ $mMissingRevIDs

ApiPageSet::$mMissingRevIDs = array()
private

Definition at line 67 of file ApiPageSet.php.

Referenced by getMissingRevisionIDs().

◆ $mMissingTitles

ApiPageSet::$mMissingTitles = array()
private

Definition at line 57 of file ApiPageSet.php.

Referenced by getMissingTitles().

◆ $mNormalizedTitles

ApiPageSet::$mNormalizedTitles = array()
private

Definition at line 62 of file ApiPageSet.php.

Referenced by getNormalizedTitles().

◆ $mParams

ApiPageSet::$mParams
private

Definition at line 49 of file ApiPageSet.php.

◆ $mPendingRedirectIDs

ApiPageSet::$mPendingRedirectIDs = array()
private

Definition at line 64 of file ApiPageSet.php.

◆ $mRedirectTitles

ApiPageSet::$mRedirectTitles = array()
private

Definition at line 60 of file ApiPageSet.php.

Referenced by getRedirectTitles().

◆ $mRequestedPageFields

ApiPageSet::$mRequestedPageFields = array()
private

Definition at line 70 of file ApiPageSet.php.

◆ $mResolveRedirects

ApiPageSet::$mResolveRedirects
private

Definition at line 50 of file ApiPageSet.php.

Referenced by isResolvingRedirects().

◆ $mSpecialTitles

ApiPageSet::$mSpecialTitles = array()
private

Definition at line 61 of file ApiPageSet.php.

Referenced by getSpecialTitles().

◆ $mTitles

ApiPageSet::$mTitles = array()
private

Definition at line 55 of file ApiPageSet.php.

Referenced by getTitles().

◆ DISABLE_GENERATORS

const ApiPageSet::DISABLE_GENERATORS = 1

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

Since
1.21

Definition at line 46 of file ApiPageSet.php.

Referenced by __construct(), and executeInternal().


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