MediaWiki REL1_33
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)
 
 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.
 
 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.
 
 getDeletedRevisionIDs ()
 Get the list of revision IDs that were associated with deleted titles.
 
 getGoodAndMissingTitles ()
 Title objects for good and missing titles.
 
 getGoodAndMissingTitlesByNamespace ()
 Returns an array [ns][dbkey] => page_id for all good and missing titles.
 
 getGoodTitleCount ()
 Returns the number of found unique pages (not revisions) in the set.
 
 getGoodTitles ()
 Title objects that were found in the database.
 
 getGoodTitlesByNamespace ()
 Returns an array [ns][dbkey] => page_id for all good titles.
 
 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.
 
 getInvalidTitlesAndReasons ()
 Titles that were deemed invalid by Title::newFromText() The array's index will be unique and negative for each item.
 
 getInvalidTitlesAndRevisions ( $invalidChecks=[ 'invalidTitles', 'special', 'missingIds', 'missingRevIds', 'missingTitles', 'interwikiTitles'])
 Get an array of invalid/special/missing titles.
 
 getLiveRevisionIDs ()
 Get the list of non-deleted revision IDs (requested with the revids= parameter)
 
 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.
 
 getMissingTitlesByNamespace ()
 Returns an array [ns][dbkey] => fake_page_id for all missing titles.
 
 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.
 
 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 valid 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.
 
 populateGeneratorData (&$result, array $path=[])
 Populate the generator data for all titles in the result.
 
 processDbRow ( $row)
 Extract all requested fields from the row received from the database.
 
 requestField ( $fieldName)
 Request an additional field from the page table.
 
 setGeneratorData (Title $title, array $data)
 Set data for a title.
 
 setRedirectMergePolicy ( $callable)
 Controls how generator data about a redirect source is merged into the generator data for the redirect target.
 
- Public Member Functions inherited from ApiBase
 __construct (ApiMain $mainModule, $moduleName, $modulePrefix='')
 
 getModuleManager ()
 Get the module manager, or null if this module has no sub-modules.
 
 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.
 
 getHelpUrls ()
 Return links to more detailed help pages about the module.
 
 shouldCheckMaxlag ()
 Indicates if this module needs maxlag to be checked.
 
 isReadMode ()
 Indicates whether this module requires read rights.
 
 isWriteMode ()
 Indicates whether this module requires write mode.
 
 mustBePosted ()
 Indicates whether this module must be called with a POST request.
 
 isDeprecated ()
 Indicates whether this module is deprecated.
 
 isInternal ()
 Indicates whether this module is "internal" Internal API modules are not (yet) intended for 3rd party use and may be unstable.
 
 needsToken ()
 Returns the token type this module requires in order to execute.
 
 getConditionalRequestData ( $condition)
 Returns data for HTTP conditional request mechanisms.
 
 getModuleName ()
 Get the name of the module being executed by this instance.
 
 getModulePrefix ()
 Get parameter prefix (usually two letters or an empty string).
 
 getMain ()
 Get the main module.
 
 isMain ()
 Returns true if this module is the main module ($this === $this->mMainModule), false otherwise.
 
 getParent ()
 Get the parent of this module.
 
 lacksSameOriginSecurity ()
 Returns true if the current request breaks the same-origin policy.
 
 getModulePath ()
 Get the path to this module.
 
 getModuleFromPath ( $path)
 Get a module from its module path.
 
 getResult ()
 Get the result object.
 
 getErrorFormatter ()
 Get the error formatter.
 
 getContinuationManager ()
 Get the continuation manager.
 
 setContinuationManager (ApiContinuationManager $manager=null)
 Set the continuation manager.
 
 dynamicParameterDocumentation ()
 Indicate if the module supports dynamically-determined parameters that cannot be included in self::getAllowedParams().
 
 encodeParamName ( $paramName)
 This method mangles parameter name based on the prefix supplied to the constructor.
 
 extractRequestParams ( $options=[])
 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.
 
 requireOnlyOneParameter ( $params, $required)
 Die if none or more than one of a certain set of parameters is set and not false.
 
 requireMaxOneParameter ( $params, $required)
 Die if more than one of a certain set of parameters is set and not false.
 
 requireAtLeastOneParameter ( $params, $required)
 Die if none of a certain set of parameters is set and not false.
 
 requirePostedParameters ( $params, $prefix='prefix')
 Die if any of the specified parameters were found in the query part of the URL rather than the post body.
 
 getTitleOrPageId ( $params, $load=false)
 Get a WikiPage object from a title or pageid param, if possible.
 
 getTitleFromTitleOrPageId ( $params)
 Get a Title object from a title or pageid param, if possible.
 
 validateToken ( $token, array $params)
 Validate the supplied token.
 
 getWatchlistUser ( $params)
 Gets the user for whom to get the watchlist.
 
 errorArrayToStatus (array $errors, User $user=null)
 Turn an array of message keys or key+param arrays into a Status.
 
 addBlockInfoToStatus (StatusValue $status, User $user=null)
 Add block info to block messages in a Status.
 
 addWarning ( $msg, $code=null, $data=null)
 Add a warning for this module.
 
 addDeprecation ( $msg, $feature, $data=[])
 Add a deprecation warning for this module.
 
 addError ( $msg, $code=null, $data=null)
 Add an error for this module without aborting.
 
 addMessagesFromStatus (StatusValue $status, $types=[ 'warning', 'error'], array $filter=[])
 Add warnings and/or errors from a Status.
 
 dieWithError ( $msg, $code=null, $data=null, $httpCode=null)
 Abort execution with an error.
 
 dieWithException ( $exception, array $options=[])
 Abort execution with an error derived from an exception.
 
 dieBlocked (Block $block)
 Throw an ApiUsageException, which will (if uncaught) call the main module's error handler and die with an error message including block info.
 
 dieStatus (StatusValue $status)
 Throw an ApiUsageException based on the Status object.
 
 dieReadOnly ()
 Helper function for readonly errors.
 
 checkUserRightsAny ( $rights, $user=null)
 Helper function for permission-denied errors.
 
 checkTitleUserPermissions (Title $title, $actions, $options=[])
 Helper function for permission-denied errors.
 
 dieWithErrorOrDebug ( $msg, $code=null, $data=null, $httpCode=null)
 Will only set a warning instead of failing if the global $wgDebugAPI is set to true.
 
 logFeatureUsage ( $feature)
 Write logging information for API features to a debug log, for usage analysis.
 
 getFinalSummary ()
 Get final module summary.
 
 getFinalDescription ()
 Get final module description, after hooks have had a chance to tweak it as needed.
 
 getFinalParams ( $flags=0)
 Get final list of parameters, after hooks have had a chance to tweak it as needed.
 
 getFinalParamDescription ()
 Get final parameter descriptions, after hooks have had a chance to tweak it as needed.
 
 modifyHelp (array &$help, array $options, array &$tocData)
 Called from ApiHelp before the pieces are joined together and returned.
 
- Public Member Functions inherited from ContextSource
 canUseWikiPage ()
 Check whether a WikiPage object can be get with getWikiPage().
 
 exportSession ()
 Export the resolved user IP, HTTP headers, user ID, and session ID.
 
 getConfig ()
 
 getContext ()
 Get the base IContextSource object.
 
 getLanguage ()
 
 getOutput ()
 
 getRequest ()
 
 getSkin ()
 
 getStats ()
 
 getTiming ()
 
 getTitle ()
 
 getUser ()
 
 getWikiPage ()
 Get the WikiPage object.
 
 msg ( $key)
 Get a Message object with context set Parameters are the same as wfMessage()
 
 setContext (IContextSource $context)
 

Public Attributes

const DISABLE_GENERATORS = 1
 Constructor flag: The new instance of ApiPageSet will ignore the 'generator=' parameter.
 
- Public Attributes inherited from ApiBase
const ALL_DEFAULT_STRING = '*'
 
const GET_VALUES_FOR_HELP = 1
 getAllowedParams() flag: When set, the result could take longer to generate, but should be more thorough.
 
const LIMIT_BIG1 = 500
 Fast query, standard limit.
 
const LIMIT_BIG2 = 5000
 Fast query, apihighlimits limit.
 
const LIMIT_SML1 = 50
 Slow query, standard limit.
 
const LIMIT_SML2 = 500
 Slow query, apihighlimits limit.
 
const PARAM_DFLT = 0
 (null|boolean|integer|string) Default value of the parameter.
 
const PARAM_ISMULTI = 1
 (boolean) Accept multiple pipe-separated values for this parameter (e.g.
 
const PARAM_TYPE = 2
 (string|string[]) Either an array of allowed value strings, or a string type as described below.
 
const PARAM_MAX = 3
 (integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
 
const PARAM_MAX2 = 4
 (integer) Max value allowed for the parameter for users with the apihighlimits right, for PARAM_TYPE 'limit'.
 
const PARAM_MIN = 5
 (integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
 
const PARAM_ALLOW_DUPLICATES = 6
 (boolean) Allow the same value to be set more than once when PARAM_ISMULTI is true?
 
const PARAM_DEPRECATED = 7
 (boolean) Is the parameter deprecated (will show a warning)?
 
const PARAM_REQUIRED = 8
 (boolean) Is the parameter required?
 
const PARAM_RANGE_ENFORCE = 9
 (boolean) For PARAM_TYPE 'integer', enforce PARAM_MIN and PARAM_MAX?
 
const PARAM_HELP_MSG = 10
 (string|array|Message) Specify an alternative i18n documentation message for this parameter.
 
const PARAM_HELP_MSG_APPEND = 11
 ((string|array|Message)[]) Specify additional i18n messages to append to the normal message for this parameter.
 
const PARAM_HELP_MSG_INFO = 12
 (array) Specify additional information tags for the parameter.
 
const PARAM_VALUE_LINKS = 13
 (string[]) When PARAM_TYPE is an array, this may be an array mapping those values to page titles which will be linked in the help.
 
const PARAM_HELP_MSG_PER_VALUE = 14
 ((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg for ApiBase::makeMessage().
 
const PARAM_SUBMODULE_MAP = 15
 (string[]) When PARAM_TYPE is 'submodule', map parameter values to submodule paths.
 
const PARAM_SUBMODULE_PARAM_PREFIX = 16
 (string) When PARAM_TYPE is 'submodule', used to indicate the 'g' prefix added by ApiQueryGeneratorBase (and similar if anything else ever does that).
 
const PARAM_ALL = 17
 (boolean|string) When PARAM_TYPE has a defined set of values and PARAM_ISMULTI is true, this allows for an asterisk ('*') to be passed in place of a pipe-separated list of every possible value.
 
const PARAM_EXTRA_NAMESPACES = 18
 (int[]) When PARAM_TYPE is 'namespace', include these as additional possible values.
 
const PARAM_SENSITIVE = 19
 (boolean) Is the parameter sensitive? Note 'password'-type fields are always sensitive regardless of the value of this field.
 
const PARAM_DEPRECATED_VALUES = 20
 (array) When PARAM_TYPE is an array, this indicates which of the values are deprecated.
 
const PARAM_ISMULTI_LIMIT1 = 21
 (integer) Maximum number of values, for normal users.
 
const PARAM_ISMULTI_LIMIT2 = 22
 (integer) Maximum number of values, for users with the apihighimits right.
 
const PARAM_MAX_BYTES = 23
 (integer) Maximum length of a string in bytes (in UTF-8 encoding).
 
const PARAM_MAX_CHARS = 24
 (integer) Maximum length of a string in characters (unicode codepoints).
 
const PARAM_TEMPLATE_VARS = 25
 (array) Indicate that this is a templated parameter, and specify replacements.
 

Protected Member Functions

 getDB ()
 Get the database connection (read-only)
 
 handleParamNormalization ( $paramName, $value, $rawValue)
 Handle when a parameter was Unicode-normalized.
 
- Protected Member Functions inherited from ApiBase
 getExamplesMessages ()
 Returns usage examples for this module.
 
 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.
 
 getWebUITokenSalt (array $params)
 Fetch the salt used in the Web UI corresponding to this module.
 
 getParameter ( $paramName, $parseLimit=true)
 Get a value for the given parameter.
 
 getWatchlistValue ( $watchlist, $titleObj, $userOption=null)
 Return true if we're to watch the page, false if not, null if no change.
 
 getParameterFromSettings ( $paramName, $paramSettings, $parseLimit)
 Using the settings determine the value for the given parameter.
 
 explodeMultiValue ( $value, $limit)
 Split a multi-valued parameter string, like explode()
 
 parseMultiValue ( $valueName, $value, $allowMultiple, $allowedValues, $allSpecifier=null, $limit1=null, $limit2=null)
 Return an array of values that were given in a 'a|b|c' notation, after it optionally validates them against the list allowed values.
 
 validateLimit ( $paramName, &$value, $min, $max, $botMax=null, $enforceLimits=false)
 Validate the value against the minimum and user/bot maximum limits.
 
 validateTimestamp ( $value, $encParamName)
 Validate and normalize parameters of type 'timestamp'.
 
 setWatch ( $watch, $titleObj, $userOption=null)
 Set a watch (or unwatch) based the based on a watchlist parameter.
 
 useTransactionalTimeLimit ()
 Call wfTransactionalTimeLimit() if this request was POSTed.
 
 filterIDs ( $fields, array $ids)
 Filter out-of-range values from a list of positive integer IDs.
 
 dieContinueUsageIf ( $condition)
 Die with the 'badcontinue' error.
 
 getSummaryMessage ()
 Return the summary message.
 
 getExtendedDescription ()
 Return the extended help text message.
 
 getHelpFlags ()
 Generates the list of flags for the help screen and for action=paraminfo.
 
 getModuleSourceInfo ()
 Returns information about the source of this module, if known.
 
 getDescription ()
 Returns the description string for this module.
 
 getParamDescription ()
 Returns an array of parameter descriptions.
 
 getExamples ()
 Returns usage examples for this module.
 
 getDescriptionMessage ()
 Return the description message.
 

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, $filterIds=true)
 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, $flags=[], $name=null)
 Add all items from $values into the result.
 

Private Attributes

 $mAllowGenerator
 
 $mAllPages = []
 
 $mAllSpecials = []
 
 $mCacheMode = 'public'
 
 $mConvertedTitles = []
 
 $mConvertTitles
 
 $mDbSource
 
int $mDefaultNamespace = NS_MAIN
 
 $mDeletedRevIDs = []
 
 $mFakePageId = -1
 
 $mGeneratorData = []
 
 $mGoodAndMissingPages = []
 
 $mGoodPages = []
 
 $mGoodRevIDs = []
 
 $mGoodTitles = []
 
 $mInterwikiTitles = []
 
array $mInvalidTitles = []
 [fake_page_id] => [ 'title' => $title, 'invalidreason' => $reason ]
 
 $mLiveRevIDs = []
 
 $mMissingPageIDs = []
 
 $mMissingPages = []
 
 $mMissingRevIDs = []
 
 $mMissingTitles = []
 
 $mNormalizedTitles = []
 
 $mParams
 
Title[] $mPendingRedirectIDs = []
 
 $mPendingRedirectSpecialPages = []
 
callable null $mRedirectMergePolicy
 
 $mRedirectTitles = []
 
 $mRequestedPageFields = []
 
 $mResolvedRedirectTitles = []
 
 $mResolveRedirects
 
 $mSpecialTitles = []
 
 $mTitles = []
 

Static Private Attributes

static $generators = null
 

Additional Inherited Members

- Static Public Member Functions inherited from ApiBase
static makeMessage ( $msg, IContextSource $context, array $params=null)
 Create a Message from a string or array.
 
static truncateArray (&$arr, $limit)
 Truncate an array to a certain length.
 
- Static Protected Member Functions inherited from ApiBase
static dieDebug ( $method, $message)
 Internal code errors should be reported with this method.
 

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

Constructor & Destructor Documentation

◆ __construct()

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

References and(), DISABLE_GENERATORS, and ApiBase\extractRequestParams().

Member Function Documentation

◆ addValues()

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

Add all items from $values into the result.

Parameters
array$resultOutput
array$valuesValues to add
string[]$flagsThe names of boolean flags to mark this element
string$nameIf given, name of the value

Definition at line 93 of file ApiPageSet.php.

References ApiQueryBase\addTitleInfo(), and and().

Referenced by getInvalidTitlesAndRevisions().

◆ execute()

ApiPageSet::execute ( )

Populate the PageSet from the request parameters.

Reimplemented from ApiBase.

Definition at line 139 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 132 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 148 of file ApiPageSet.php.

References $generator, $mDbSource, ApiBase\addWarning(), and(), ApiBase\dieWithError(), ApiBase\encodeParamName(), ApiBase\getMain(), initFromPageIds(), initFromRevIDs(), initFromTitles(), and resolvePendingRedirects().

Referenced by execute(), and executeDryRun().

◆ getAllowedParams()

◆ 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 343 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
array | null$params
Returns
string
Since
1.21

Definition at line 1146 of file ApiPageSet.php.

References $mCacheMode.

◆ getConvertedTitles()

ApiPageSet::getConvertedTitles ( )

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 524 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
ApiResult | null$result
Returns
array Array of (from, to) strings
Since
1.21

Definition at line 535 of file ApiPageSet.php.

References and(), getConvertedTitles(), and ApiResult\setIndexedTagName().

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

References and().

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

References and().

◆ getDB()

ApiPageSet::getDB ( )
protected

Get the database connection (read-only)

Returns
IDatabase

Reimplemented from ApiBase.

Definition at line 1417 of file ApiPageSet.php.

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

◆ getDeletedRevisionIDs()

ApiPageSet::getDeletedRevisionIDs ( )

Get the list of revision IDs that were associated with deleted titles.

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

Definition at line 667 of file ApiPageSet.php.

References $mDeletedRevIDs.

◆ getGenerators()

ApiPageSet::getGenerators ( )
private

Get an array of all available generators.

Returns
array

Definition at line 1490 of file ApiPageSet.php.

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

Referenced by getAllowedParams().

◆ getGoodAndMissingTitles()

ApiPageSet::getGoodAndMissingTitles ( )

Title objects for good and missing titles.

Returns
array

Definition at line 417 of file ApiPageSet.php.

References $mMissingTitles.

◆ getGoodAndMissingTitlesByNamespace()

ApiPageSet::getGoodAndMissingTitlesByNamespace ( )

Returns an array [ns][dbkey] => page_id for all good and missing titles.

Returns
array

Definition at line 409 of file ApiPageSet.php.

References $mGoodAndMissingPages.

◆ getGoodTitleCount()

ApiPageSet::getGoodTitleCount ( )

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

Returns
int

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

References $mGoodTitles.

◆ getGoodTitlesByNamespace()

ApiPageSet::getGoodTitlesByNamespace ( )

Returns an array [ns][dbkey] => page_id for all good titles.

Returns
array

Definition at line 367 of file ApiPageSet.php.

References $mGoodPages.

◆ getInterwikiTitles()

ApiPageSet::getInterwikiTitles ( )

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 555 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
ApiResult | null$result
bool$iwUrl
Returns
array Array of raw_prefixed_title (string) => interwiki_prefix (string)
Since
1.21

Definition at line 567 of file ApiPageSet.php.

References and(), getInterwikiTitles(), PROTO_CURRENT, and ApiResult\setIndexedTagName().

Referenced by getInvalidTitlesAndRevisions().

◆ getInvalidTitlesAndReasons()

ApiPageSet::getInvalidTitlesAndReasons ( )

Titles that were deemed invalid by Title::newFromText() The array's index will be unique and negative for each item.

Returns
array[] Array of arrays with 'title' and 'invalidreason' properties

Definition at line 426 of file ApiPageSet.php.

References $mInvalidTitles.

Referenced by getInvalidTitlesAndRevisions().

◆ getInvalidTitlesAndRevisions()

ApiPageSet::getInvalidTitlesAndRevisions ( $invalidChecks = [ '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 601 of file ApiPageSet.php.

References $result, $title, addValues(), and(), getInterwikiTitlesAsResult(), getInvalidTitlesAndReasons(), getMissingPageIDs(), getMissingRevisionIDs(), getMissingTitles(), and getSpecialTitles().

◆ getLiveRevisionIDs()

ApiPageSet::getLiveRevisionIDs ( )

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

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

Definition at line 659 of file ApiPageSet.php.

References $mLiveRevIDs.

◆ getMissingPageIDs()

ApiPageSet::getMissingPageIDs ( )

Page IDs that were not found in the database.

Returns
array Array of page IDs

Definition at line 434 of file ApiPageSet.php.

References $mMissingPageIDs.

Referenced by getInvalidTitlesAndRevisions().

◆ getMissingRevisionIDs()

ApiPageSet::getMissingRevisionIDs ( )

Revision IDs that were not found in the database.

Returns
array Array of revision IDs

Definition at line 675 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
ApiResult | null$result
Returns
array Array of revision IDs
Since
1.21

Definition at line 685 of file ApiPageSet.php.

References getMissingRevisionIDs(), and ApiResult\setIndexedTagName().

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

References $mMissingTitles.

Referenced by getInvalidTitlesAndRevisions().

◆ getMissingTitlesByNamespace()

ApiPageSet::getMissingTitlesByNamespace ( )

Returns an array [ns][dbkey] => fake_page_id for all missing titles.

fake_page_id is a unique negative number.

Returns
array

Definition at line 392 of file ApiPageSet.php.

References $mMissingPages.

◆ getNormalizedTitles()

ApiPageSet::getNormalizedTitles ( )

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 490 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
ApiResult | null$result
Returns
array Array of raw_prefixed_title (string) => prefixed_title (string)
Since
1.21

Definition at line 501 of file ApiPageSet.php.

References and(), getNormalizedTitles(), and ApiResult\setIndexedTagName().

◆ 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 Array of field names

Definition at line 307 of file ApiPageSet.php.

References and(), and ContextSource\getConfig().

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

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

References $res, $title, and(), getDB(), list, and processTitlesArray().

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

Definition at line 443 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.

Includes generator data for redirect source when available.

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

Definition at line 454 of file ApiPageSet.php.

References and(), getRedirectTitles(), and ApiResult\setIndexedTagName().

◆ getRevisionCount()

ApiPageSet::getRevisionCount ( )

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

Returns
int Number of revisions.

Definition at line 711 of file ApiPageSet.php.

References getRevisionIDs().

◆ getRevisionIDs()

ApiPageSet::getRevisionIDs ( )

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

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

Definition at line 651 of file ApiPageSet.php.

References $mGoodRevIDs.

Referenced by getRevisionCount().

◆ getSpecialTitles()

ApiPageSet::getSpecialTitles ( )

Get the list of titles with negative namespace.

Returns
Title[]

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

◆ getTitles()

ApiPageSet::getTitles ( )

All Title objects provided.

Returns
Title[]

Definition at line 351 of file ApiPageSet.php.

References $mTitles.

◆ handleParamNormalization()

ApiPageSet::handleParamNormalization ( $paramName,
$value,
$rawValue )
protected

Handle when a parameter was Unicode-normalized.

Since
1.28
Parameters
string$paramNameUnprefixed parameter name
string$valueInput that will be used.
string$rawValueInput before normalization.

Reimplemented from ApiBase.

Definition at line 1467 of file ApiPageSet.php.

References $value, and(), and ApiBase\explodeMultiValue().

◆ initFromPageIds()

ApiPageSet::initFromPageIds ( $pageids,
$filterIds = true )
private

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

Parameters
array$pageidsArray of page IDs
bool$filterIdsWhether the IDs need filtering

Definition at line 824 of file ApiPageSet.php.

References $res, and(), ApiBase\filterIDs(), getDB(), getPageTableFields(), initFromQueryResult(), 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
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 864 of file ApiPageSet.php.

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

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$revidsArray of revision IDs

Definition at line 935 of file ApiPageSet.php.

References $res, $tables, $titles, and(), ApiBase\filterIDs(), getDB(), ContextSource\getUser(), initFromPageIds(), and initFromTitles().

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

Definition at line 796 of file ApiPageSet.php.

References $res, $titles, getDB(), getPageTableFields(), initFromQueryResult(), processTitlesArray(), and resolvePendingRedirects().

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

◆ isResolvingRedirects()

ApiPageSet::isResolvingRedirects ( )

Check whether this PageSet is resolving redirects.

Returns
bool

Definition at line 253 of file ApiPageSet.php.

References $mResolveRedirects.

◆ populateFromPageIDs()

ApiPageSet::populateFromPageIDs ( $pageIDs)

Populate this PageSet from a list of page IDs.

Parameters
array$pageIDsArray of page IDs

Definition at line 727 of file ApiPageSet.php.

References initFromPageIds().

◆ populateFromQueryResult()

ApiPageSet::populateFromQueryResult ( $db,
$queryResult )

Populate this PageSet from a rowset returned from the database.

Note that the query result must include the columns returned by $this->getPageTableFields().

Parameters
IDatabase$db
ResultWrapper$queryResult

Definition at line 740 of file ApiPageSet.php.

References initFromQueryResult().

◆ populateFromRevisionIDs()

ApiPageSet::populateFromRevisionIDs ( $revIDs)

Populate this PageSet from a list of revision IDs.

Parameters
array$revIDsArray of revision IDs

Definition at line 748 of file ApiPageSet.php.

References initFromRevIDs().

◆ populateFromTitles()

ApiPageSet::populateFromTitles ( $titles)

Populate this PageSet from a list of Titles.

Parameters
array$titlesArray of Title objects

Definition at line 719 of file ApiPageSet.php.

References $titles, and initFromTitles().

◆ populateGeneratorData()

ApiPageSet::populateGeneratorData ( & $result,
array $path = [] )

Populate the generator data for all titles in the result.

The page data may be inserted into an ApiResult object or into an associative array. The $path parameter specifies the path within the ApiResult or array to find the "pages" node.

The "pages" node itself must be an associative array mapping the page ID or fake page ID values returned by this pageset (see self::getAllTitlesByNamespace() and self::getSpecialTitles()) to associative arrays of page data. Each of those subarrays will have the data from self::setGeneratorData() merged in.

Data that was set by self::setGeneratorData() for pages not in the "pages" node will be ignored.

Parameters
ApiResult | array&$result
array$path
Returns
bool Whether the data fit

Definition at line 1327 of file ApiPageSet.php.

References $data, $result, $value, ApiResult\addValue(), and(), NS_SPECIAL, and ApiResult\OVERRIDE.

◆ processDbRow()

ApiPageSet::processDbRow ( $row)

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

Parameters
stdClass$rowResult row

Definition at line 756 of file ApiPageSet.php.

References $title, and and().

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$titlesArray of Title objects or strings
Returns
LinkBatch

Definition at line 1159 of file ApiPageSet.php.

References ContextSource\$context, $mFakePageId, $services, $title, $titles, and(), ApiBase\getErrorFormatter(), list, and NS_SPECIAL.

Referenced by getRedirectTargets(), and 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 287 of file ApiPageSet.php.

References and().

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

References $res, getDB(), getPageTableFields(), getRedirectTargets(), and initFromQueryResult().

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

◆ setGeneratorData()

ApiPageSet::setGeneratorData ( Title $title,
array $data )

Set data for a title.

This data may be extracted into an ApiResult using self::populateGeneratorData. This should generally be limited to data that is likely to be particularly useful to end users rather than just being a dump of everything returned in non-generator mode.

Redirects here will not be followed, even if 'redirects' was specified, since in the case of multiple redirects we can't know which source's data to use on the target.

Parameters
Title$title
array$data

Definition at line 1278 of file ApiPageSet.php.

References $data.

◆ setRedirectMergePolicy()

ApiPageSet::setRedirectMergePolicy ( $callable)

Controls how generator data about a redirect source is merged into the generator data for the redirect target.

When not set no data is merged. Note that if multiple titles redirect to the same target the order of operations is undefined.

Example to include generated data from redirect in target, prefering the data generated for the destination when there is a collision:

$pageSet->setRedirectMergePolicy( function( array $current, array $new ) {
return $current + $new;
} );
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
Parameters
callable | null$callableRecieves two array arguments, first the generator data for the redirect target and second the generator data for the redirect source. Returns the resulting generator data to use for the redirect target.

Definition at line 1303 of file ApiPageSet.php.

Member Data Documentation

◆ $generators

ApiPageSet::$generators = null
staticprivate

Definition at line 1484 of file ApiPageSet.php.

Referenced by getGenerators().

◆ $mAllowGenerator

ApiPageSet::$mAllowGenerator
private

Definition at line 51 of file ApiPageSet.php.

◆ $mAllPages

ApiPageSet::$mAllPages = []
private

Definition at line 53 of file ApiPageSet.php.

Referenced by getAllTitlesByNamespace().

◆ $mAllSpecials

ApiPageSet::$mAllSpecials = []
private

Definition at line 65 of file ApiPageSet.php.

◆ $mCacheMode

ApiPageSet::$mCacheMode = 'public'
private

Definition at line 79 of file ApiPageSet.php.

Referenced by getCacheMode().

◆ $mConvertedTitles

ApiPageSet::$mConvertedTitles = []
private

Definition at line 72 of file ApiPageSet.php.

Referenced by getConvertedTitles().

◆ $mConvertTitles

ApiPageSet::$mConvertTitles
private

Definition at line 50 of file ApiPageSet.php.

◆ $mDbSource

ApiPageSet::$mDbSource
private

Definition at line 47 of file ApiPageSet.php.

Referenced by executeInternal(), and getGenerators().

◆ $mDefaultNamespace

int ApiPageSet::$mDefaultNamespace = NS_MAIN
private

Definition at line 82 of file ApiPageSet.php.

◆ $mDeletedRevIDs

ApiPageSet::$mDeletedRevIDs = []
private

Definition at line 75 of file ApiPageSet.php.

Referenced by getDeletedRevisionIDs().

◆ $mFakePageId

ApiPageSet::$mFakePageId = -1
private

Definition at line 78 of file ApiPageSet.php.

Referenced by initFromQueryResult(), and processTitlesArray().

◆ $mGeneratorData

ApiPageSet::$mGeneratorData = []
private

Definition at line 77 of file ApiPageSet.php.

◆ $mGoodAndMissingPages

ApiPageSet::$mGoodAndMissingPages = []
private

Definition at line 55 of file ApiPageSet.php.

Referenced by getGoodAndMissingTitlesByNamespace().

◆ $mGoodPages

ApiPageSet::$mGoodPages = []
private

Definition at line 56 of file ApiPageSet.php.

Referenced by getGoodTitlesByNamespace().

◆ $mGoodRevIDs

ApiPageSet::$mGoodRevIDs = []
private

Definition at line 73 of file ApiPageSet.php.

Referenced by getRevisionIDs().

◆ $mGoodTitles

ApiPageSet::$mGoodTitles = []
private

Definition at line 57 of file ApiPageSet.php.

Referenced by getGoodTitles().

◆ $mInterwikiTitles

ApiPageSet::$mInterwikiTitles = []
private

Definition at line 67 of file ApiPageSet.php.

Referenced by getInterwikiTitles().

◆ $mInvalidTitles

array ApiPageSet::$mInvalidTitles = []
private

[fake_page_id] => [ 'title' => $title, 'invalidreason' => $reason ]

Definition at line 61 of file ApiPageSet.php.

Referenced by getInvalidTitlesAndReasons().

◆ $mLiveRevIDs

ApiPageSet::$mLiveRevIDs = []
private

Definition at line 74 of file ApiPageSet.php.

Referenced by getLiveRevisionIDs().

◆ $mMissingPageIDs

ApiPageSet::$mMissingPageIDs = []
private

Definition at line 62 of file ApiPageSet.php.

Referenced by getMissingPageIDs().

◆ $mMissingPages

ApiPageSet::$mMissingPages = []
private

Definition at line 58 of file ApiPageSet.php.

Referenced by getMissingTitlesByNamespace().

◆ $mMissingRevIDs

ApiPageSet::$mMissingRevIDs = []
private

Definition at line 76 of file ApiPageSet.php.

Referenced by getMissingRevisionIDs().

◆ $mMissingTitles

ApiPageSet::$mMissingTitles = []
private

Definition at line 59 of file ApiPageSet.php.

Referenced by getGoodAndMissingTitles(), and getMissingTitles().

◆ $mNormalizedTitles

ApiPageSet::$mNormalizedTitles = []
private

Definition at line 66 of file ApiPageSet.php.

Referenced by getNormalizedTitles().

◆ $mParams

ApiPageSet::$mParams
private

Definition at line 48 of file ApiPageSet.php.

◆ $mPendingRedirectIDs

Title [] ApiPageSet::$mPendingRedirectIDs = []
private

Definition at line 69 of file ApiPageSet.php.

◆ $mPendingRedirectSpecialPages

ApiPageSet::$mPendingRedirectSpecialPages = []
private

Definition at line 70 of file ApiPageSet.php.

◆ $mRedirectMergePolicy

callable null ApiPageSet::$mRedirectMergePolicy
private

Definition at line 84 of file ApiPageSet.php.

◆ $mRedirectTitles

ApiPageSet::$mRedirectTitles = []
private

Definition at line 63 of file ApiPageSet.php.

Referenced by getRedirectTitles().

◆ $mRequestedPageFields

ApiPageSet::$mRequestedPageFields = []
private

Definition at line 80 of file ApiPageSet.php.

◆ $mResolvedRedirectTitles

ApiPageSet::$mResolvedRedirectTitles = []
private

Definition at line 71 of file ApiPageSet.php.

◆ $mResolveRedirects

ApiPageSet::$mResolveRedirects
private

Definition at line 49 of file ApiPageSet.php.

Referenced by isResolvingRedirects().

◆ $mSpecialTitles

ApiPageSet::$mSpecialTitles = []
private

Definition at line 64 of file ApiPageSet.php.

Referenced by getSpecialTitles().

◆ $mTitles

ApiPageSet::$mTitles = []
private

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

Referenced by __construct().


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