BlueSpice MediaWiki REL1_27
 All Classes Namespaces Files Functions Variables Groups Pages
ApiPageSet Class Reference
Inheritance diagram for ApiPageSet:
Collaboration diagram for ApiPageSet:

Public Member Functions

 __construct (ApiBase $dbSource, $flags=0, $defaultNamespace=NS_MAIN)
 
 executeDryRun ()
 
 execute ()
 
 isResolvingRedirects ()
 
 getDataSource ()
 
 requestField ($fieldName)
 
 getCustomField ($fieldName)
 
 getPageTableFields ()
 
 getAllTitlesByNamespace ()
 
 getTitles ()
 
 getTitleCount ()
 
 getGoodTitlesByNamespace ()
 
 getGoodTitles ()
 
 getGoodTitleCount ()
 
 getMissingTitlesByNamespace ()
 
 getMissingTitles ()
 
 getGoodAndMissingTitlesByNamespace ()
 
 getGoodAndMissingTitles ()
 
 getInvalidTitles ()
 
 getInvalidTitlesAndReasons ()
 
 getMissingPageIDs ()
 
 getRedirectTitles ()
 
 getRedirectTitlesAsResult ($result=null)
 
 getNormalizedTitles ()
 
 getNormalizedTitlesAsResult ($result=null)
 
 getConvertedTitles ()
 
 getConvertedTitlesAsResult ($result=null)
 
 getInterwikiTitles ()
 
 getInterwikiTitlesAsResult ($result=null, $iwUrl=false)
 
 getInvalidTitlesAndRevisions ($invalidChecks=[ 'invalidTitles', 'special', 'missingIds', 'missingRevIds', 'missingTitles', 'interwikiTitles'])
 
 getRevisionIDs ()
 
 getLiveRevisionIDs ()
 
 getDeletedRevisionIDs ()
 
 getMissingRevisionIDs ()
 
 getMissingRevisionIDsAsResult ($result=null)
 
 getSpecialTitles ()
 
 getRevisionCount ()
 
 populateFromTitles ($titles)
 
 populateFromPageIDs ($pageIDs)
 
 populateFromQueryResult ($db, $queryResult)
 
 populateFromRevisionIDs ($revIDs)
 
 processDbRow ($row)
 
 getCacheMode ($params=null)
 
 setGeneratorData (Title $title, array $data)
 
 setRedirectMergePolicy ($callable)
 
 populateGeneratorData (&$result, array $path=[])
 
 getAllowedParams ($flags=0)
 
- Public Member Functions inherited from ApiBase
 __construct (ApiMain $mainModule, $moduleName, $modulePrefix= '')
 
 execute ()
 
 getModuleManager ()
 
 getCustomPrinter ()
 
 getHelpUrls ()
 
 shouldCheckMaxlag ()
 
 isReadMode ()
 
 isWriteMode ()
 
 mustBePosted ()
 
 isDeprecated ()
 
 isInternal ()
 
 needsToken ()
 
 getConditionalRequestData ($condition)
 
 getModuleName ()
 
 getModulePrefix ()
 
 getMain ()
 
 isMain ()
 
 getParent ()
 
 lacksSameOriginSecurity ()
 
 getModulePath ()
 
 getModuleFromPath ($path)
 
 getResult ()
 
 getErrorFormatter ()
 
 getContinuationManager ()
 
 setContinuationManager ($manager)
 
 dynamicParameterDocumentation ()
 
 encodeParamName ($paramName)
 
 extractRequestParams ($parseLimit=true)
 
 requireOnlyOneParameter ($params, $required)
 
 requireMaxOneParameter ($params, $required)
 
 requireAtLeastOneParameter ($params, $required)
 
 requirePostedParameters ($params, $prefix= 'prefix')
 
 getTitleOrPageId ($params, $load=false)
 
 validateToken ($token, array $params)
 
 getWatchlistUser ($params)
 
 setWarning ($warning)
 
 dieUsage ($description, $errorCode, $httpRespCode=0, $extradata=null)
 
 dieBlocked (Block $block)
 
 getErrorFromStatus ($status, &$extraData=null)
 
 dieStatus ($status)
 
static dieReadOnly ()
 
 dieUsageMsg ($error)
 
 dieUsageMsgOrDebug ($error)
 
 parseMsg ($error)
 
 logFeatureUsage ($feature)
 
 getFinalDescription ()
 
 getFinalParams ($flags=0)
 
 getFinalParamDescription ()
 
 modifyHelp (array &$help, array $options, array &$tocData)
 
 makeHelpMsg ()
 
 makeHelpMsgParameters ()
 
 getModuleProfileName ($db=false)
 
 profileIn ()
 
 profileOut ()
 
 safeProfileOut ()
 
 getProfileTime ()
 
 profileDBIn ()
 
 profileDBOut ()
 
 getProfileDBTime ()
 
 getResultData ()
 
- Public Member Functions inherited from ContextSource
 getContext ()
 
 setContext (IContextSource $context)
 
 getConfig ()
 
 getRequest ()
 
 getTitle ()
 
 canUseWikiPage ()
 
 getWikiPage ()
 
 getOutput ()
 
 getUser ()
 
 getLanguage ()
 
 getSkin ()
 
 getTiming ()
 
 getStats ()
 
 msg ()
 
 exportSession ()
 

Public Attributes

const DISABLE_GENERATORS = 1
 
- Public Attributes inherited from ApiBase
const LIMIT_BIG1 = 500
 
const LIMIT_BIG2 = 5000
 
const LIMIT_SML1 = 50
 
const LIMIT_SML2 = 500
 
const GET_VALUES_FOR_HELP = 1
 
 $mModulePrefix
 
const PARAM_DFLT = 0
 
const PARAM_ISMULTI = 1
 
const PARAM_TYPE = 2
 
const PARAM_MAX = 3
 
const PARAM_MAX2 = 4
 
const PARAM_MIN = 5
 
const PARAM_ALLOW_DUPLICATES = 6
 
const PARAM_DEPRECATED = 7
 
const PARAM_REQUIRED = 8
 
const PARAM_RANGE_ENFORCE = 9
 
const PARAM_HELP_MSG = 10
 
const PARAM_HELP_MSG_APPEND = 11
 
const PARAM_HELP_MSG_INFO = 12
 
const PARAM_VALUE_LINKS = 13
 
const PARAM_HELP_MSG_PER_VALUE = 14
 
const PARAM_SUBMODULE_MAP = 15
 
const PARAM_SUBMODULE_PARAM_PREFIX = 16
 
const PARAM_SENSITIVE = 17
 

Protected Member Functions

 getDB ()
 
- Protected Member Functions inherited from ApiBase
 getExamplesMessages ()
 
 getAllowedParams ()
 
 getWebUITokenSalt (array $params)
 
 getDB ()
 
 getParameter ($paramName, $parseLimit=true)
 
 getWatchlistValue ($watchlist, $titleObj, $userOption=null)
 
 getParameterFromSettings ($paramName, $paramSettings, $parseLimit)
 
 parseMultiValue ($valueName, $value, $allowMultiple, $allowedValues)
 
 validateLimit ($paramName, &$value, $min, $max, $botMax=null, $enforceLimits=false)
 
 validateTimestamp ($value, $encParamName)
 
 setWatch ($watch, $titleObj, $userOption=null)
 
 dieContinueUsageIf ($condition)
 
 getDescriptionMessage ()
 
 getHelpFlags ()
 
 getModuleSourceInfo ()
 
 getDescription ()
 
 getParamDescription ()
 
 getExamples ()
 
 makeHelpArrayToString ($prefix, $title, $input)
 
 useTransactionalTimeLimit ()
 

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

Constructor & Destructor Documentation

ApiPageSet::__construct ( ApiBase  $dbSource,
  $flags = 0,
  $defaultNamespace = NS_MAIN 
)
Parameters
ApiBase$dbSourceModule implementing getDB(). Allows PageSet to reuse existing db connection from the shared state like ApiQuery.
int$flagsZero or more flags like DISABLE_GENERATORS
int$defaultNamespaceThe namespace to use if none is specified by a prefix.
Since
1.21 accepts $flags instead of two boolean values

Member Function Documentation

ApiPageSet::execute ( )

Populate the PageSet from the request parameters.

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

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
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
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)
ApiPageSet::getConvertedTitlesAsResult (   $result = null)

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

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

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

Parameters
string$fieldNameField name
Returns
mixed Field value
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
ApiPageSet::getDB ( )
protected

Get the database connection (read-only)

Returns
DatabaseBase
ApiPageSet::getDeletedRevisionIDs ( )

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

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

Title objects for good and missing titles.

Returns
array
ApiPageSet::getGoodAndMissingTitlesByNamespace ( )

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

Returns
array
ApiPageSet::getGoodTitleCount ( )

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

Returns
int
ApiPageSet::getGoodTitles ( )

Title objects that were found in the database.

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

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

Returns
array
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)
ApiPageSet::getInterwikiTitlesAsResult (   $result = null,
  $iwUrl = false 
)

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

Parameters
ApiResult$result
bool$iwUrl
Returns
array Array of raw_prefixed_title (string) => interwiki_prefix (string)
Since
1.21
ApiPageSet::getInvalidTitles ( )

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

Deprecated:
since 1.26, use self::getInvalidTitlesAndReasons()
Returns
string[] Array of strings (not Title objects)
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
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
ApiPageSet::getLiveRevisionIDs ( )

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

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

Page IDs that were not found in the database

Returns
array Array of page IDs
ApiPageSet::getMissingRevisionIDs ( )

Revision IDs that were not found in the database

Returns
array Array of revision IDs
ApiPageSet::getMissingRevisionIDsAsResult (   $result = null)

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

Parameters
ApiResult$result
Returns
array Array of revision IDs
Since
1.21
ApiPageSet::getMissingTitles ( )

Title objects that were NOT found in the database. The array's index will be negative for each item

Returns
Title[]
ApiPageSet::getMissingTitlesByNamespace ( )

Returns an array [ns][dbkey] => fake_page_id for all missing titles. fake_page_id is a unique negative number.

Returns
array
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)
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$result
Returns
array Array of raw_prefixed_title (string) => prefixed_title (string)
Since
1.21
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
ApiPageSet::getRedirectTitles ( )

Get a list of redirect resolutions - maps a title to its redirect target, as an array of output-ready arrays

Returns
Title[]
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$result
Returns
array Array of prefixed_title (string) => Title object
Since
1.21
ApiPageSet::getRevisionCount ( )

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

Returns
int Number of revisions.
ApiPageSet::getRevisionIDs ( )

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

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

Get the list of titles with negative namespace

Returns
Title[]
ApiPageSet::getTitleCount ( )

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

Returns
int
ApiPageSet::getTitles ( )

All Title objects provided.

Returns
Title[]
ApiPageSet::isResolvingRedirects ( )

Check whether this PageSet is resolving redirects

Returns
bool
ApiPageSet::populateFromPageIDs (   $pageIDs)

Populate this PageSet from a list of page IDs

Parameters
array$pageIDsArray of page IDs
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$queryResultQuery result object
ApiPageSet::populateFromRevisionIDs (   $revIDs)

Populate this PageSet from a list of revision IDs

Parameters
array$revIDsArray of revision IDs
ApiPageSet::populateFromTitles (   $titles)

Populate this PageSet from a list of Titles

Parameters
array$titlesArray of Title objects
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
ApiPageSet::processDbRow (   $row)

Extract all requested fields from the row received from the database

Parameters
stdClass$rowResult row
ApiPageSet::requestField (   $fieldName)

Request an additional field from the page table. Must be called before execute()

Parameters
string$fieldNameField name
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
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;
} );
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.

Member Data Documentation

const ApiPageSet::DISABLE_GENERATORS = 1

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

Since
1.21

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