MediaWiki  REL1_22
ApiBase Class Reference

This abstract class implements many basic API functions, and is the base of all API classes. More...

Inheritance diagram for ApiBase:
Collaboration diagram for ApiBase:

List of all members.

Public Member Functions

 __construct ($mainModule, $moduleName, $modulePrefix= '')
 Constructor.
 createContext ()
 Create a new RequestContext object to use e.g.
 dieReadOnly ()
 Helper function for readonly errors.
 dieStatus ($status)
 Throw a UsageException based on the errors in the Status object.
 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.
 dieUsageMsg ($error)
 Output the error message related to a certain array.
 dieUsageMsgOrDebug ($error)
 Will only set a warning instead of failing if the global $wgDebugAPI is set to true.
 encodeParamName ($paramName)
 This method mangles parameter name based on the prefix supplied to the constructor.
 execute ()
 Evaluates the parameters, performs the requested query, and sets up the result.
 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.
 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.
 getFinalDescription ()
 Get final module description, 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.
 getFinalParams ($flags=0)
 Get final list of parameters, after hooks have had a chance to tweak it as needed.
 getFinalPossibleErrors ()
 Get final list of possible errors, after hooks have had a chance to tweak it as needed.
 getFinalResultProperties ()
 Get final possible result properties, after hooks have had a chance to tweak it as needed.
 getHelpUrls ()
 getMain ()
 Get the main module.
 getModuleManager ()
 Get the module manager, or null if this module has no sub-modules.
 getModuleName ()
 Get the name of the module being executed by this instance.
 getModulePrefix ()
 Get parameter prefix (usually two letters or an empty string).
 getModuleProfileName ($db=false)
 Get the name of the module as shown in the profiler log.
 getPossibleErrors ()
 Returns a list of all possible errors returned by the module.
 getProfileDBTime ()
 Total time the module used the database.
 getProfileTime ()
 Total time the module was executed.
 getRequireMaxOneParameterErrorMessages ($params)
 Generates the possible error requireMaxOneParameter() can die with.
 getRequireOnlyOneParameterErrorMessages ($params)
 Generates the possible errors requireOnlyOneParameter() can die with.
 getResult ()
 Get the result object.
 getResultData ()
 Get the result data array (read-only)
 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.
 getVersion ()
 Returns a string that identifies the version of the extending class.
 getWatchlistUser ($params)
 Gets the user for whom to get the watchlist.
 isMain ()
 Returns true if this module is the main module ($this === $this->mMainModule), false otherwise.
 isReadMode ()
 Indicates whether this module requires read rights.
 isWriteMode ()
 Indicates whether this module requires write mode.
 makeHelpMsg ()
 Generates help message for this module, or false if there is no description.
 makeHelpMsgParameters ()
 Generates the parameter descriptions for this module, to be displayed in the module's help.
 mustBePosted ()
 Indicates whether this module must be called with a POST request.
 needsToken ()
 Returns whether this module requires a token to execute It is used to show possible errors in action=paraminfo see bug 25248.
 parseErrors ($errors)
 Parses a list of errors into a standardised format.
 parseMsg ($error)
 Return the error message related to a certain array.
 profileDBIn ()
 Start module profiling.
 profileDBOut ()
 End database profiling.
 profileIn ()
 Start module profiling.
 profileOut ()
 End module profiling.
 requireMaxOneParameter ($params)
 Die if more than one of a certain set of parameters is set and not false.
 requireOnlyOneParameter ($params)
 Die if none or more than one of a certain set of parameters is set and not false.
 safeProfileOut ()
 When modules crash, sometimes it is needed to do a profileOut() regardless of the profiling state the module was in.
 setWarning ($warning)
 Set warning section for this module.
 shouldCheckMaxlag ()
 Indicates if this module needs maxlag to be checked.
 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 of parameters of type 'timestamp'.

Static Public Member Functions

static debugPrint ($value, $name= 'unknown', $backtrace=false)
 Debugging function that prints a value and an optional backtrace.
static getValidNamespaces ()
static truncateArray (&$arr, $limit)
 Truncate an array to a certain length.

Public Attributes

 $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.
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

Static Public Attributes

static $messageMap
 Array that maps message keys to error messages.

Protected Member Functions

 dieContinueUsageIf ($condition)
 Die with the $prefix.
 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.
 getDB ()
 Gets a default slave database connection object.
 getDescription ()
 Returns the description string for this module.
 getExamples ()
 Returns usage examples for this module.
 getParamDescription ()
 Returns an array of parameter descriptions.
 getParameter ($paramName, $parseLimit=true)
 Get a value for the given parameter.
 getParameterFromSettings ($paramName, $paramSettings, $parseLimit)
 Using the settings determine the value for the given parameter.
 getResultProperties ()
 Returns possible properties in the result, grouped by the value of the prop parameter that shows them.
 getWatchlistValue ($watchlist, $titleObj, $userOption=null)
 Return true if we're to watch the page, false if not, null if no change.
 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.
 setWatch ($watch, $titleObj, $userOption=null)
 Set a watch (or unwatch) based the based on a watchlist parameter.

Static Protected Member Functions

static addTokenProperties (&$props, $tokenFunctions)
 Add token properties to the array used by getResultProperties, based on a token functions mapping.
static dieDebug ($method, $message)
 Internal code errors should be reported with this method.

Private Member Functions

 indentExampleText ($item)
 parameterNotEmpty ($x)
 Callback function used in requireOnlyOneParameter to check whether required parameters are set.
 validateUser ($value, $encParamName)
 Validate and normalize of parameters of type 'user'.
 warnOrDie ($msg, $enforceLimits=false)
 Adds a warning to the output, else dies.

Private Attributes

 $mDBTimeIn = 0
 Profiling: database execution time.
 $mMainModule
 $mParamCache = array()
 $mSlaveDB = null
 $mTimeIn = 0
 Profiling: total module execution time.

Detailed Description

This abstract class implements many basic API functions, and is the base of all API classes.

The class functions are divided into several areas of functionality:

Module parameters: Derived classes can define getAllowedParams() to specify which parameters to expect, how to parse and validate them.

Profiling: various methods to allow keeping tabs on various tasks and their time costs

Self-documentation: code to allow the API to document its own state

Definition at line 42 of file ApiBase.php.


Constructor & Destructor Documentation

ApiBase::__construct ( mainModule,
moduleName,
modulePrefix = '' 
)

Constructor.

Parameters:
$mainModuleApiMain object
string$moduleNameName of this module
string$modulePrefixPrefix to use for parameter names

Reimplemented in ApiQueryImageInfo.

Definition at line 86 of file ApiBase.php.

References isMain(), and ContextSource\setContext().


Member Function Documentation

static ApiBase::addTokenProperties ( &$  props,
tokenFunctions 
) [static, protected]

Add token properties to the array used by getResultProperties, based on a token functions mapping.

Definition at line 609 of file ApiBase.php.

References array(), as, PROP_NULLABLE, and PROP_TYPE.

Referenced by ApiTokens\getResultProperties(), ApiQueryUsers\getResultProperties(), ApiQueryRecentChanges\getResultProperties(), ApiQueryRevisions\getResultProperties(), and ApiQueryInfo\getResultProperties().

Create a new RequestContext object to use e.g.

for calls to other parts the software. The object will have the WebRequest and the User object set to the ones used in this instance.

Deprecated:
since 1.19 use getContext to get the current context
Returns:
DerivativeContext

Definition at line 217 of file ApiBase.php.

References ContextSource\getContext(), and wfDeprecated().

static ApiBase::debugPrint ( value,
name = 'unknown',
backtrace = false 
) [static]

Debugging function that prints a value and an optional backtrace.

Parameters:
$valuemixed Value to print
string$nameDescription of the printed value
bool$backtraceIf true, print a backtrace

Definition at line 1804 of file ApiBase.php.

References $value, print, and wfBacktrace().

Helper function for readonly errors.

Definition at line 1420 of file ApiBase.php.

References array(), dieUsage(), parseMsg(), and wfReadOnlyReason().

Referenced by ApiEditPage\execute().

ApiBase::dieStatus ( status)

Throw a UsageException based on the errors in the Status object.

Since:
1.22
Parameters:
Status$statusStatus object
Exceptions:
UsageException

Definition at line 1226 of file ApiBase.php.

References $messageMap, array(), dieUsage(), and wfMessage().

Referenced by ApiCreateAccount\execute(), ApiProtect\execute(), ApiWatch\execute(), ApiImport\execute(), ApiDelete\execute(), and ApiUserrights\getUrUser().

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

Parameters:
string$descriptionOne-line human-readable description of the error condition, e.g., "The API requires a valid action parameter"
string$errorCodeBrief, arbitrary, stable string to allow easy automated identification of the error, e.g., 'unknown_action'
int$httpRespCodeHTTP response code
array$extradataData to add to the "<error>" element; array in ApiResult format
Exceptions:
UsageException

Definition at line 1214 of file ApiBase.php.

References encodeParamName(), and Profiler\instance().

Referenced by ApiQuerySiteinfo\appendDbReplLagInfo(), dieContinueUsageIf(), dieReadOnly(), dieStatus(), dieUsageMsg(), ApiComparePages\execute(), ApiCreateAccount\execute(), ApiQueryStashImageInfo\execute(), ApiWatch\execute(), ApiEditPage\execute(), ApiPatrol\execute(), ApiSetNotificationTimestamp\execute(), ApiHelp\execute(), ApiQueryDeletedrevs\execute(), ApiOptions\execute(), ApiQueryAllMessages\execute(), ApiUpload\execute(), ApiDisabled\execute(), ApiQueryFilearchive\execute(), ApiFeedContributions\execute(), ApiQueryBlocks\execute(), ApiQueryLogEvents\execute(), ApiQueryContributions\execute(), ApiQueryAllUsers\execute(), ApiFeedWatchlist\execute(), ApiQueryRevisions\execute(), ApiQueryAllPages\executeGenerator(), ApiQueryAllImages\executeGenerator(), ApiQueryRevisions\extractRowInfo(), getParameterFromSettings(), ApiQueryImageInfo\getScale(), getTitleOrPageId(), getWatchlistUser(), ApiQueryImageInfo\mergeThumbParams(), parseMultiValue(), ApiQueryContributions\prepareQuery(), ApiQueryBase\prepareUrlQuerySearchString(), ApiQueryContributions\prepareUsername(), ApiQueryBlocks\prepareUsername(), requireMaxOneParameter(), requireOnlyOneParameter(), ApiComparePages\revisionOrTitleOrId(), ApiQueryCategoryMembers\run(), ApiQueryWatchlist\run(), ApiQuerySearch\run(), ApiQueryAllPages\run(), ApiQueryAllImages\run(), ApiQueryAllLinks\run(), ApiQueryRecentChanges\run(), validateTimestamp(), validateUser(), and warnOrDie().

Will only set a warning instead of failing if the global $wgDebugAPI is set to true.

Otherwise behaves exactly as dieUsageMsg().

Parameters:
$error(array|string) Element of a getUserPermissionsErrors()-style array
Since:
1.21

Definition at line 1446 of file ApiBase.php.

References $error, array(), dieUsageMsg(), global, parseMsg(), and setWarning().

ApiBase::encodeParamName ( paramName)

This method mangles parameter name based on the prefix supplied to the constructor.

Override this method to change parameter name during runtime

Parameters:
string$paramNameParameter name
Returns:
string Prefixed parameter name

Reimplemented in ApiQueryGeneratorBase.

Definition at line 636 of file ApiBase.php.

Referenced by dieUsage(), getParameterFromSettings(), makeHelpMsgParameters(), ApiQueryBase\setContinueEnumParameter(), and validateLimit().

ApiBase::execute ( ) [abstract]

Evaluates the parameters, performs the requested query, and sets up the result.

Concrete implementations of ApiBase must override this method to provide whatever functionality their module offers. Implementations must not produce any output on their own and are not expected to handle any errors.

The execute() method will be invoked directly by ApiMain immediately before the result of the module is output. Aside from the constructor, implementations should assume that no other methods will be called externally on the module before the result is processed.

The result data should be stored in the ApiResult object available through getResult().

Reimplemented in ApiResult, ApiFormatFeedWrapper, ApiMain, ApiQueryInfo, ApiQuery, MockApi, ApiQueryRecentChanges, ApiPageSet, ApiQueryBacklinks, ApiQueryRevisions, ApiQueryORM, ApiQueryAllLinks, ApiQueryUsers, ApiQueryLinks, ApiPurge, ApiFormatJson, ApiFormatRaw, ApiImageRotate, ApiQueryAllImages, ApiFeedWatchlist, ApiQueryQueryPage, ApiFormatXml, ApiLogin, ApiQueryAllUsers, ApiOpenSearch, ApiQueryFileRepoInfo, ApiQuerySearch, ApiQueryTags, ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryPagePropNames, ApiQueryContributions, ApiDelete, ApiQueryBlocks, ApiQueryRandom, ApiBlock, ApiFeedContributions, ApiParamInfo, ApiFormatDbg, ApiFormatDump, ApiFormatTxt, ApiQueryFilearchive, ApiQueryPageProps, ApiQueryUserInfo, ApiRollback, ApiDisabled, ApiFileRevert, ApiQueryAllCategories, ApiQueryCategoryInfo, ApiQueryDisabled, ApiQueryImages, ApiQueryIWLinks, ApiQueryPagesWithProp, ApiQueryWatchlist, ApiQueryWatchlistRaw, ApiOptions, ApiQueryAllMessages, ApiQueryAllPages, ApiQueryCategories, ApiQueryCategoryMembers, ApiQueryDeletedrevs, ApiQueryDuplicateFiles, ApiQueryExternalLinks, ApiQueryIWBacklinks, ApiQueryLangBacklinks, ApiQueryLangLinks, ApiQueryProtectedTitles, ApiQuerySiteinfo, ApiUnblock, ApiUpload, ApiFormatNone, ApiFormatPhp, ApiFormatWddx, ApiHelp, ApiEditPage, ApiExpandTemplates, ApiParse, ApiPatrol, ApiQueryExtLinksUsage, ApiSetNotificationTimestamp, ApiLogout, ApiUserrights, ApiImport, ApiQueryStashImageInfo, ApiRsd, ApiWatch, ApiEmailUser, ApiMove, ApiProtect, ApiTokens, ApiUndelete, ApiCreateAccount, and ApiComparePages.

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

limits will not be parsed if $parseLimit is set to false; use this when the max limit is not definitive yet, e.g. when getting revisions.

Parameters:
$parseLimitBoolean: true by default
Returns:
array

Definition at line 649 of file ApiBase.php.

References $params, array(), as, getFinalParams(), and getParameterFromSettings().

Referenced by ApiQuerySiteinfo\appendInterwikiMap(), ApiQuerySiteinfo\appendLanguages(), ApiComparePages\execute(), ApiCreateAccount\execute(), ApiTokens\execute(), ApiUndelete\execute(), ApiProtect\execute(), ApiMove\execute(), ApiEmailUser\execute(), ApiQueryStashImageInfo\execute(), ApiImport\execute(), ApiWatch\execute(), ApiUserrights\execute(), ApiSetNotificationTimestamp\execute(), ApiEditPage\execute(), ApiPatrol\execute(), ApiExpandTemplates\execute(), ApiHelp\execute(), ApiUnblock\execute(), ApiQueryDeletedrevs\execute(), ApiQueryExternalLinks\execute(), ApiOptions\execute(), ApiUpload\execute(), ApiQueryLangLinks\execute(), ApiQueryAllMessages\execute(), ApiQuerySiteinfo\execute(), ApiQueryCategoryInfo\execute(), ApiFileRevert\execute(), ApiQueryIWLinks\execute(), ApiQueryUserInfo\execute(), ApiRollback\execute(), ApiQueryFilearchive\execute(), ApiQueryPageProps\execute(), ApiFeedContributions\execute(), ApiBlock\execute(), ApiParamInfo\execute(), ApiDelete\execute(), ApiQueryBlocks\execute(), ApiQueryContributions\execute(), ApiQueryLogEvents\execute(), ApiQueryPagePropNames\execute(), ApiQueryImageInfo\execute(), ApiQueryTags\execute(), ApiOpenSearch\execute(), ApiQueryFileRepoInfo\execute(), ApiQueryAllUsers\execute(), ApiLogin\execute(), ApiFormatXml\execute(), ApiFeedWatchlist\execute(), ApiImageRotate\execute(), ApiFormatJson\execute(), ApiPurge\execute(), ApiQueryUsers\execute(), ApiQueryRevisions\execute(), ApiQueryInfo\execute(), ApiOpenSearch\getCustomPrinter(), ApiFormatJson\getMimeType(), ApiQueryORM\getParams(), ApiUserrights\getUrUser(), ApiQueryIWBacklinks\run(), ApiQueryLangBacklinks\run(), ApiQueryImages\run(), ApiQueryProtectedTitles\run(), ApiQueryWatchlistRaw\run(), ApiQueryExtLinksUsage\run(), ApiQueryDuplicateFiles\run(), ApiQueryCategories\run(), ApiQueryAllCategories\run(), ApiQueryCategoryMembers\run(), ApiQueryWatchlist\run(), ApiQueryPagesWithProp\run(), ApiQuerySearch\run(), ApiQueryAllPages\run(), ApiQueryQueryPage\run(), ApiQueryAllImages\run(), ApiQueryLinks\run(), ApiQueryAllLinks\run(), ApiQueryRandom\run(), and ApiQueryRecentChanges\run().

ApiBase::getAllowedParams ( ) [protected]

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.

Some derived classes may choose to handle an integer $flags parameter in the overriding methods. Callers of this method can pass zero or more OR-ed flags like GET_VALUES_FOR_HELP.

Returns:
array|bool

Reimplemented in ApiMain, ApiQueryInfo, ApiUpload, ApiQuerySiteinfo, ApiQueryRevisions, ApiParse, ApiQueryRecentChanges, ApiEditPage, ApiQueryImageInfo, ApiQueryBacklinks, ApiQueryLogEvents, ApiQueryContributions, ApiQueryWatchlist, ApiQueryAllUsers, ApiParamInfo, ApiQueryDeletedrevs, ApiQueryUsers, ApiQueryAllImages, ApiQueryCategoryMembers, ApiQueryBlocks, ApiQueryORM, MockApi, ApiQueryAllLinks, ApiQueryFilearchive, ApiQueryAllPages, ApiFormatXml, ApiQuerySearch, ApiQueryAllMessages, ApiQueryUserInfo, ApiQueryLinks, ApiQueryCategories, ApiMove, ApiLogin, ApiCreateAccount, ApiDelete, ApiQueryDuplicateFiles, ApiQueryIWBacklinks, ApiQueryLangBacklinks, ApiQueryAllCategories, ApiQueryProtectedTitles, ApiFeedContributions, ApiQueryExtLinksUsage, ApiBlock, ApiQueryQueryPage, ApiQueryRandom, ApiQueryImages, ApiQueryIWLinks, ApiQueryTags, ApiQueryWatchlistRaw, ApiOptions, ApiHelp, ApiProtect, ApiQueryPagesWithProp, ApiQueryLangLinks, ApiQueryPageProps, ApiFileRevert, ApiQueryExternalLinks, ApiComparePages, ApiImport, ApiQueryCategoryInfo, ApiWatch, ApiUndelete, ApiOpenSearch, ApiEmailUser, ApiUnblock, ApiUserrights, ApiQueryPagePropNames, ApiExpandTemplates, ApiPatrol, ApiQueryStashImageInfo, ApiRollback, ApiFormatJson, ApiTokens, ApiQueryFileRepoInfo, ApiRsd, ApiLogout, ApiDisabled, and ApiQueryDisabled.

Definition at line 531 of file ApiBase.php.

Referenced by getFinalParams().

If the module may only be used with a certain format module, it should override this method to return an instance of that formatter.

A value of null means the default format will be used.

Returns:
mixed instance of a derived class of ApiFormatBase, or null

Reimplemented in ApiQuery, ApiRsd, ApiFeedWatchlist, ApiFeedContributions, and ApiOpenSearch.

Definition at line 262 of file ApiBase.php.

ApiBase::getDB ( ) [protected]

Gets a default slave database connection object.

Returns:
DatabaseBase

Reimplemented in ApiPageSet, ApiQueryBase, and ApiQueryAllImages.

Definition at line 1789 of file ApiBase.php.

References profileDBIn(), profileDBOut(), and wfGetDB().

Referenced by ApiProtect\execute(), and ApiBlock\execute().

ApiBase::getDescription ( ) [protected]

Returns the description string for this module.

Returns:
mixed string or array of strings

Reimplemented in ApiMain, ApiQueryInfo, ApiQueryRevisions, ApiUpload, ApiQueryRecentChanges, ApiQueryImageInfo, ApiQuerySiteinfo, ApiQuery, ApiParse, ApiQueryWatchlist, ApiQueryLogEvents, ApiQueryContributions, ApiQueryBacklinks, ApiEditPage, ApiQueryAllUsers, ApiQueryBlocks, ApiQueryCategoryMembers, ApiQueryUsers, ApiQueryDeletedrevs, ApiQuerySearch, ApiQueryAllImages, ApiQueryFilearchive, ApiParamInfo, ApiQueryAllPages, ApiFormatBase, ApiQueryAllLinks, ApiQueryUserInfo, ApiQueryAllMessages, ApiMove, ApiSetNotificationTimestamp, ApiFeedWatchlist, ApiQueryExtLinksUsage, ApiLogin, ApiQueryCategories, ApiQueryProtectedTitles, ApiQueryLinks, ApiFormatXml, ApiDelete, ApiQueryIWBacklinks, ApiQueryLangBacklinks, ApiQueryAllCategories, ApiBlock, ApiPurge, ApiQueryWatchlistRaw, ApiImageRotate, ApiQueryDuplicateFiles, ApiQueryQueryPage, ApiProtect, ApiFeedContributions, ApiQueryTags, ApiOptions, ApiQueryImages, ApiQueryIWLinks, ApiQueryRandom, ApiQueryPagesWithProp, ApiQueryLangLinks, ApiFileRevert, ApiCreateAccount, ApiComparePages, ApiQueryExternalLinks, ApiHelp, ApiImport, ApiQueryPageProps, ApiUndelete, ApiQueryCategoryInfo, ApiEmailUser, ApiWatch, ApiQueryStashImageInfo, ApiUnblock, ApiRollback, ApiOpenSearch, ApiUserrights, ApiPatrol, ApiExpandTemplates, ApiFormatWddx, ApiQueryFileRepoInfo, ApiQueryPagePropNames, ApiTokens, ApiFormatJson, ApiRsd, ApiLogout, ApiDisabled, ApiQueryDisabled, ApiFormatDump, ApiFormatDbg, ApiFormatTxt, ApiFormatPhp, ApiFormatNone, and ApiFormatYaml.

Definition at line 507 of file ApiBase.php.

Referenced by getFinalDescription().

ApiBase::getExamples ( ) [protected]

Returns usage examples for this module.

Return false if no examples are available.

Returns:
bool|string|array

Reimplemented in ApiQueryInfo, ApiUpload, ApiQueryRevisions, ApiQueryRecentChanges, ApiQueryImageInfo, ApiParse, ApiQuery, ApiQuerySiteinfo, ApiEditPage, ApiQueryWatchlist, ApiQueryLogEvents, ApiQueryContributions, ApiQueryBacklinks, ApiQueryAllUsers, ApiQueryBlocks, ApiQueryDeletedrevs, ApiQueryCategoryMembers, ApiQueryUsers, ApiQueryAllImages, ApiQuerySearch, ApiQueryFilearchive, ApiParamInfo, ApiQueryAllPages, ApiQueryAllLinks, ApiFormatBase, ApiQueryUserInfo, ApiMove, ApiQueryAllMessages, ApiSetNotificationTimestamp, ApiCreateAccount, ApiLogin, ApiFeedWatchlist, ApiQueryExtLinksUsage, ApiQueryCategories, ApiQueryProtectedTitles, ApiDelete, ApiBlock, ApiQueryLangBacklinks, ApiQueryLinks, ApiQueryIWBacklinks, ApiImageRotate, ApiQueryAllCategories, ApiProtect, ApiPurge, ApiQueryWatchlistRaw, ApiQueryQueryPage, ApiOptions, ApiFeedContributions, ApiQueryDuplicateFiles, ApiRollback, ApiQueryIWLinks, ApiQueryTags, ApiFileRevert, ApiQueryImages, ApiQueryRandom, ApiQueryLangLinks, ApiQueryPagesWithProp, ApiImport, ApiComparePages, ApiUndelete, ApiQueryExternalLinks, ApiHelp, ApiUnblock, ApiEmailUser, ApiQueryPageProps, ApiQueryCategoryInfo, ApiWatch, ApiPatrol, ApiQueryStashImageInfo, ApiUserrights, ApiOpenSearch, ApiExpandTemplates, ApiQueryFileRepoInfo, ApiQueryPagePropNames, ApiTokens, ApiRsd, ApiLogout, ApiDisabled, and ApiQueryDisabled.

Definition at line 515 of file ApiBase.php.

Referenced by makeHelpMsg().

Get final module description, after hooks have had a chance to tweak it as needed.

Returns:
array|bool False on no parameters

Definition at line 624 of file ApiBase.php.

References array(), getDescription(), and wfRunHooks().

Referenced by makeHelpMsg().

Get final parameter descriptions, after hooks have had a chance to tweak it as needed.

Returns:
array|bool False on no parameter descriptions

Definition at line 567 of file ApiBase.php.

References array(), getParamDescription(), and wfRunHooks().

Referenced by makeHelpMsgParameters().

ApiBase::getFinalParams ( flags = 0)

Get final list of parameters, after hooks have had a chance to tweak it as needed.

Parameters:
int$flagsZero or more flags like GET_VALUES_FOR_HELP
Returns:
array|Bool False on no parameters
Since:
1.21 $flags param added

Definition at line 555 of file ApiBase.php.

References $flags, $params, array(), getAllowedParams(), and wfRunHooks().

Referenced by extractRequestParams(), getParameter(), getPossibleErrors(), and makeHelpMsgParameters().

Get final list of possible errors, after hooks have had a chance to tweak it as needed.

Returns:
array
Since:
1.22

Definition at line 1656 of file ApiBase.php.

References array(), getPossibleErrors(), and wfRunHooks().

Referenced by ApiPurge\getPossibleErrors(), and ApiQuery\getPossibleErrors().

Get final possible result properties, after hooks have had a chance to tweak it as needed.

Returns:
array

Definition at line 599 of file ApiBase.php.

References array(), getResultProperties(), and wfRunHooks().

Get the module manager, or null if this module has no sub-modules.

Since:
1.21
Returns:
ApiModuleManager

Reimplemented in ApiMain, and ApiQuery.

Definition at line 143 of file ApiBase.php.

Get the name of the module being executed by this instance.

Returns:
string

Definition at line 134 of file ApiBase.php.

Referenced by ApiQueryBase\addPageSubItem(), ApiQueryBase\addPageSubItems(), ApiQueryTags\doTag(), ApiComparePages\execute(), ApiProtect\execute(), ApiTokens\execute(), ApiUndelete\execute(), ApiEmailUser\execute(), ApiMove\execute(), ApiWatch\execute(), ApiQueryStashImageInfo\execute(), ApiImport\execute(), ApiUserrights\execute(), ApiExpandTemplates\execute(), ApiPatrol\execute(), ApiEditPage\execute(), ApiSetNotificationTimestamp\execute(), ApiHelp\execute(), ApiUpload\execute(), ApiOptions\execute(), ApiQueryDeletedrevs\execute(), ApiQueryAllMessages\execute(), ApiUnblock\execute(), ApiFileRevert\execute(), ApiQueryFilearchive\execute(), ApiQueryUserInfo\execute(), ApiRollback\execute(), ApiParamInfo\execute(), ApiBlock\execute(), ApiQueryBlocks\execute(), ApiDelete\execute(), ApiQueryContributions\execute(), ApiQueryLogEvents\execute(), ApiQueryPagePropNames\execute(), ApiQueryTags\execute(), ApiQueryAllUsers\execute(), ApiImageRotate\execute(), ApiPurge\execute(), ApiQueryUsers\execute(), ApiQueryRevisions\execute(), ApiQueryLinks\getExamples(), ApiFormatBase\getExamples(), ApiQueryAllLinks\getExamples(), ApiQueryAllLinks\getHelpUrls(), getParameterFromSettings(), ApiQueryAllLinks\getPossibleErrors(), getPossibleErrors(), ApiQueryLangBacklinks\run(), ApiQueryIWBacklinks\run(), ApiQueryProtectedTitles\run(), ApiQueryWatchlistRaw\run(), ApiQueryExtLinksUsage\run(), ApiQueryCategoryMembers\run(), ApiQueryAllCategories\run(), ApiQueryPagesWithProp\run(), ApiQueryWatchlist\run(), ApiQuerySearch\run(), ApiQueryAllPages\run(), ApiQueryQueryPage\run(), ApiQueryAllImages\run(), ApiQueryAllLinks\run(), ApiQueryRandom\run(), ApiQueryRecentChanges\run(), ApiQueryRandom\runQuery(), ApiQueryBase\setContinueEnumParameter(), and setWarning().

Get parameter prefix (usually two letters or an empty string).

Returns:
string

Definition at line 151 of file ApiBase.php.

Referenced by ApiQueryBase\addPageSubItem(), ApiQueryBase\addPageSubItems(), ApiQueryStashImageInfo\execute(), ApiQueryDeletedrevs\getDescription(), ApiQueryAllLinks\getExamples(), ApiQueryFileRepoInfo\getParamDescription(), ApiUnblock\getParamDescription(), ApiQueryStashImageInfo\getParamDescription(), ApiQueryExternalLinks\getParamDescription(), ApiProtect\getParamDescription(), ApiQueryProtectedTitles\getParamDescription(), ApiCreateAccount\getParamDescription(), ApiDelete\getParamDescription(), ApiQueryExtLinksUsage\getParamDescription(), ApiMove\getParamDescription(), ApiQueryAllLinks\getParamDescription(), ApiQueryAllPages\getParamDescription(), ApiQueryBlocks\getParamDescription(), ApiQueryCategoryMembers\getParamDescription(), ApiQueryAllImages\getParamDescription(), ApiQueryDeletedrevs\getParamDescription(), ApiQueryContributions\getParamDescription(), ApiQueryWatchlist\getParamDescription(), ApiQueryLogEvents\getParamDescription(), ApiQueryImageInfo\getParamDescription(), ApiEditPage\getParamDescription(), ApiQueryRecentChanges\getParamDescription(), ApiQuerySiteinfo\getParamDescription(), ApiQueryRevisions\getParamDescription(), ApiQueryAllImages\getPossibleErrors(), ApiQueryImageInfo\getPossibleErrors(), getRequireMaxOneParameterErrorMessages(), getRequireOnlyOneParameterErrorMessages(), ApiQueryImageInfo\getScale(), ApiQueryImageInfo\mergeThumbParams(), requireMaxOneParameter(), requireOnlyOneParameter(), ApiQueryProtectedTitles\run(), ApiQueryExtLinksUsage\run(), and ApiQueryAllImages\run().

Get the name of the module as shown in the profiler log.

Parameters:
$dbDatabaseBase|bool
Returns:
string

Definition at line 162 of file ApiBase.php.

Referenced by profileDBIn(), profileDBOut(), profileIn(), and profileOut().

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 in ApiPageSet, ApiMain, ApiQueryInfo, ApiUpload, ApiQueryRevisions, ApiQuery, ApiQuerySiteinfo, ApiParse, ApiQueryRecentChanges, ApiEditPage, ApiQueryImageInfo, ApiQueryBacklinks, ApiQueryLogEvents, ApiQueryWatchlist, ApiQueryContributions, ApiQueryAllUsers, ApiQueryDeletedrevs, ApiParamInfo, ApiQueryAllImages, ApiQueryCategoryMembers, ApiQueryBlocks, ApiQueryUsers, ApiQueryAllPages, ApiQuerySearch, ApiQueryAllLinks, ApiQueryFilearchive, ApiQueryORM, ApiFeedWatchlist, ApiQueryAllMessages, ApiFormatXml, ApiMove, ApiQueryCategories, ApiQueryUserInfo, ApiSetNotificationTimestamp, ApiQueryLinks, ApiQueryExtLinksUsage, ApiDelete, ApiCreateAccount, ApiImageRotate, ApiQueryProtectedTitles, ApiQueryIWBacklinks, ApiQueryLangBacklinks, ApiLogin, ApiQueryAllCategories, ApiQueryDuplicateFiles, ApiFeedContributions, ApiQueryWatchlistRaw, ApiOptions, ApiProtect, ApiBlock, ApiPurge, ApiQueryImages, ApiQueryQueryPage, ApiQueryPagesWithProp, ApiQueryRandom, ApiQueryIWLinks, ApiQueryTags, ApiQueryLangLinks, ApiHelp, ApiFileRevert, ApiQueryPageProps, ApiQueryExternalLinks, ApiImport, ApiComparePages, ApiUndelete, ApiOpenSearch, ApiQueryStashImageInfo, ApiWatch, ApiUserrights, ApiEmailUser, ApiQueryCategoryInfo, ApiRollback, ApiUnblock, ApiQueryPagePropNames, ApiExpandTemplates, ApiPatrol, ApiTokens, ApiQueryFileRepoInfo, ApiFormatJson, ApiRsd, ApiLogout, ApiDisabled, and ApiQueryDisabled.

Definition at line 543 of file ApiBase.php.

Referenced by getFinalParamDescription().

ApiBase::getParameter ( paramName,
parseLimit = true 
) [protected]

Get a value for the given parameter.

Parameters:
string$paramNameParameter name
bool$parseLimitsee extractRequestParams()
Returns:
mixed Parameter value

Definition at line 672 of file ApiBase.php.

References $params, getFinalParams(), and getParameterFromSettings().

Referenced by ApiMain\sendCacheHeaders().

ApiBase::getParameterFromSettings ( paramName,
paramSettings,
parseLimit 
) [protected]

Using the settings determine the value for the given parameter.

Parameters:
string$paramNameparameter name
array | mixed$paramSettingsdefault value or an array of settings using PARAM_* constants.
$parseLimitBoolean: parse limit?
Returns:
mixed Parameter value

Definition at line 880 of file ApiBase.php.

References $key, $value, array(), as, dieDebug(), dieUsage(), dieUsageMsg(), encodeParamName(), getMain(), getModuleName(), getResult(), getValidNamespaces(), PARAM_ALLOW_DUPLICATES, PARAM_DEPRECATED, PARAM_DFLT, PARAM_ISMULTI, PARAM_MAX, PARAM_MAX2, PARAM_MIN, PARAM_RANGE_ENFORCE, PARAM_REQUIRED, PARAM_TYPE, parseMultiValue(), setWarning(), validateLimit(), validateTimestamp(), and validateUser().

Referenced by extractRequestParams(), and getParameter().

Total time the module used the database.

Returns:
float

Definition at line 1778 of file ApiBase.php.

References dieDebug().

Total time the module was executed.

Returns:
float

Definition at line 1729 of file ApiBase.php.

References dieDebug().

Generates the possible error requireMaxOneParameter() can die with.

Parameters:
$paramsarray
Returns:
array

Definition at line 737 of file ApiBase.php.

References $params, array(), and getModulePrefix().

Referenced by ApiSetNotificationTimestamp\getPossibleErrors().

Get the result object.

Returns:
ApiResult

Reimplemented in ApiMain.

Definition at line 191 of file ApiBase.php.

References dieDebug(), getMain(), and isMain().

Referenced by ApiQueryBase\addPageSubItem(), ApiQueryBase\addPageSubItems(), ApiQueryORM\addSerializedResults(), ApiQuerySiteinfo\appendDbReplLagInfo(), ApiQuerySiteinfo\appendExtensions(), ApiQuerySiteinfo\appendExtensionTags(), ApiQuerySiteinfo\appendFileExtensions(), ApiQuerySiteinfo\appendFunctionHooks(), ApiQuerySiteinfo\appendGeneralInfo(), ApiQuerySiteinfo\appendInterwikiMap(), ApiQuerySiteinfo\appendLanguages(), ApiQuerySiteinfo\appendMagicWords(), ApiQuerySiteinfo\appendNamespaceAliases(), ApiQuerySiteinfo\appendNamespaces(), ApiQuerySiteinfo\appendProtocols(), ApiQuerySiteinfo\appendRightsInfo(), ApiQuerySiteinfo\appendSkins(), ApiQuerySiteinfo\appendSpecialPageAliases(), ApiQuerySiteinfo\appendStatistics(), ApiQuerySiteinfo\appendSubscribedHooks(), ApiQuerySiteinfo\appendUserGroups(), ApiQuerySiteinfo\appendVariables(), ApiComparePages\execute(), ApiCreateAccount\execute(), ApiProtect\execute(), ApiTokens\execute(), ApiUndelete\execute(), ApiMove\execute(), ApiEmailUser\execute(), ApiImport\execute(), ApiQueryStashImageInfo\execute(), ApiRsd\execute(), ApiWatch\execute(), ApiUserrights\execute(), ApiEditPage\execute(), ApiExpandTemplates\execute(), ApiSetNotificationTimestamp\execute(), ApiPatrol\execute(), ApiHelp\execute(), ApiUnblock\execute(), ApiQueryDeletedrevs\execute(), ApiOptions\execute(), ApiUpload\execute(), ApiQueryAllMessages\execute(), ApiFileRevert\execute(), ApiQueryFilearchive\execute(), ApiQueryUserInfo\execute(), ApiRollback\execute(), ApiQueryPageProps\execute(), ApiBlock\execute(), ApiFeedContributions\execute(), ApiParamInfo\execute(), ApiQueryBlocks\execute(), ApiDelete\execute(), ApiQueryPagePropNames\execute(), ApiQueryLogEvents\execute(), ApiQueryContributions\execute(), ApiQueryImageInfo\execute(), ApiQueryTags\execute(), ApiOpenSearch\execute(), ApiQueryFileRepoInfo\execute(), ApiQueryAllUsers\execute(), ApiLogin\execute(), ApiFeedWatchlist\execute(), ApiImageRotate\execute(), ApiPurge\execute(), ApiQueryUsers\execute(), ApiQueryRevisions\execute(), ApiQueryInfo\execute(), ApiQueryInfo\extractPageInfo(), ApiQueryWatchlist\extractRowInfo(), ApiQueryContributions\extractRowInfo(), ApiQueryLogEvents\extractRowInfo(), ApiQueryRecentChanges\extractRowInfo(), ApiQueryRevisions\extractRowInfo(), ApiRsd\formatRsdApiList(), ApiQueryUserInfo\getCurrentUserInfo(), getParameterFromSettings(), getResultData(), ApiQueryLangBacklinks\run(), ApiQueryIWBacklinks\run(), ApiQueryProtectedTitles\run(), ApiQueryWatchlistRaw\run(), ApiQueryExtLinksUsage\run(), ApiQueryAllCategories\run(), ApiQueryCategoryMembers\run(), ApiQueryPagesWithProp\run(), ApiQueryWatchlist\run(), ApiQuerySearch\run(), ApiQueryAllPages\run(), ApiQueryQueryPage\run(), ApiQueryAllImages\run(), ApiQueryAllLinks\run(), ApiQueryRandom\run(), ApiQueryRecentChanges\run(), ApiQueryRandom\runQuery(), ApiQueryBase\setContinueEnumParameter(), ApiQueryORM\setIndexedTagNames(), setWarning(), and ApiUpload\transformWarnings().

Returns possible properties in the result, grouped by the value of the prop parameter that shows them.

Properties that are shown always are in a group with empty string as a key. Properties that can be shown by several values of prop are included multiple times. If some properties are part of a list and some are on the root object (see ApiQueryQueryPage), those on the root object are under the key PROP_ROOT. The array can also contain a boolean under the key PROP_LIST, indicating whether the result is a list.

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

Returns:
array|bool False on no properties

Reimplemented in ApiQueryInfo, ApiUpload, ApiQueryRevisions, ApiQueryImageInfo, ApiQueryRecentChanges, ApiEditPage, ApiQueryBacklinks, ApiQueryWatchlist, ApiQueryLogEvents, ApiQueryContributions, ApiQueryAllUsers, ApiQueryDeletedrevs, ApiQueryCategoryMembers, ApiQueryAllImages, ApiQueryBlocks, ApiQueryUsers, ApiQueryAllPages, ApiQuerySearch, ApiQueryAllLinks, ApiQueryFilearchive, ApiQueryAllMessages, ApiQueryExtLinksUsage, ApiQueryUserInfo, ApiMove, ApiQueryCategories, ApiSetNotificationTimestamp, ApiQueryLinks, ApiDelete, ApiQueryProtectedTitles, ApiCreateAccount, ApiQueryIWBacklinks, ApiQueryLangBacklinks, ApiQueryAllCategories, ApiLogin, ApiQueryWatchlistRaw, ApiQueryDuplicateFiles, ApiProtect, ApiBlock, ApiPurge, ApiQueryImages, ApiQueryTags, ApiQueryQueryPage, ApiQueryIWLinks, ApiQueryRandom, ApiQueryLangLinks, ApiOptions, ApiFileRevert, ApiQueryExternalLinks, ApiImport, ApiComparePages, ApiUndelete, ApiQueryStashImageInfo, ApiWatch, ApiRollback, ApiEmailUser, ApiQueryCategoryInfo, ApiUnblock, ApiExpandTemplates, ApiPatrol, ApiTokens, and ApiLogout.

Definition at line 589 of file ApiBase.php.

Referenced by getFinalResultProperties().

ApiBase::getTitleOrPageId ( params,
load = false 
)
Parameters:
$paramsarray
bool | string$loadWhether load the object's state from the database:
  • false: don't load (if the pageid is given, it will still be loaded)
  • 'fromdb': load from a slave database
  • 'fromdbmaster': load from the master database
Returns:
WikiPage

Definition at line 754 of file ApiBase.php.

References $params, array(), dieUsage(), dieUsageMsg(), WikiPage\factory(), WikiPage\newFromID(), Title\newFromText(), and requireOnlyOneParameter().

Referenced by ApiProtect\execute(), ApiEditPage\execute(), ApiDelete\execute(), and ApiQueryCategoryMembers\run().

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.

Returns:
bool|string|array

Reimplemented in ApiUpload, ApiEditPage, ApiMove, ApiDelete, ApiBlock, ApiProtect, ApiImageRotate, ApiOptions, ApiSetNotificationTimestamp, ApiFileRevert, ApiImport, ApiUndelete, ApiRollback, ApiUnblock, ApiEmailUser, ApiPatrol, ApiUserrights, and ApiWatch.

Definition at line 1558 of file ApiBase.php.

static ApiBase::getValidNamespaces ( ) [static]
Deprecated:
since 1.17 use MWNamespace::getValidNamespaces()
Returns:
array

Definition at line 811 of file ApiBase.php.

References wfDeprecated().

Referenced by getParameterFromSettings().

Returns a string that identifies the version of the extending class.

Typically includes the class name, the svn revision, timestamp, and last author. Usually done with SVN's Id keyword

Returns:
string
Deprecated:
since 1.21, version string is no longer supported

Reimplemented in MockApi.

Definition at line 125 of file ApiBase.php.

References wfDeprecated().

Gets the user for whom to get the watchlist.

Parameters:
$paramsarray
Returns:
User

Definition at line 1568 of file ApiBase.php.

References $params, $user, dieUsage(), ContextSource\getUser(), and User\newFromName().

Referenced by ApiQueryWatchlistRaw\run(), and ApiQueryWatchlist\run().

ApiBase::getWatchlistValue ( watchlist,
titleObj,
userOption = null 
) [protected]

Return true if we're to watch the page, false if not, null if no change.

Parameters:
string$watchlistValid values: 'watch', 'unwatch', 'preferences', 'nochange'
$titleObjTitle the page under consideration
string$userOptionThe user option to consider when $watchlist=preferences. If not set will magically default to either watchdefault or watchcreations
Returns:
bool

Definition at line 824 of file ApiBase.php.

References ContextSource\getUser(), and WatchedItem\IGNORE_USER_RIGHTS.

Referenced by ApiEditPage\execute(), and setWatch().

ApiBase::indentExampleText ( item) [private]
Parameters:
$itemstring
Returns:
string

Definition at line 337 of file ApiBase.php.

Returns true if this module is the main module ($this === $this->mMainModule), false otherwise.

Returns:
bool

Definition at line 183 of file ApiBase.php.

Referenced by __construct(), and getResult().

Indicates whether this module requires read rights.

Returns:
bool

Reimplemented in ApiMain, ApiParamInfo, ApiLogin, ApiCreateAccount, ApiHelp, ApiLogout, and ApiDisabled.

Definition at line 1521 of file ApiBase.php.

Referenced by getPossibleErrors(), and makeHelpMsg().

ApiBase::makeHelpArrayToString ( prefix,
title,
input 
) [protected]
Parameters:
string$prefixText to split output items
string$titleWhat is being output
$inputstring|array
Returns:
string

Definition at line 347 of file ApiBase.php.

References $title, and array().

Referenced by makeHelpMsg().

Generates help message for this module, or false if there is no description.

Returns:
mixed string or false

Reimplemented in ApiMain, and ApiQuery.

Definition at line 270 of file ApiBase.php.

References array(), as, getExamples(), getFinalDescription(), getHelpUrls(), isReadMode(), isWriteMode(), makeHelpArrayToString(), makeHelpMsgParameters(), and mustBePosted().

Generates the parameter descriptions for this module, to be displayed in the module's help.

Returns:
string or false

Definition at line 372 of file ApiBase.php.

References $params, $s, $t, array(), as, encodeParamName(), GET_VALUES_FOR_HELP, getFinalParamDescription(), getFinalParams(), MWNamespace\getValidNamespaces(), PARAM_DFLT, PARAM_ISMULTI, and PARAM_TYPE.

Referenced by makeHelpMsg().

Returns whether this module requires a token to execute It is used to show possible errors in action=paraminfo see bug 25248.

Returns:
bool

Reimplemented in ApiUpload, ApiEditPage, ApiMove, ApiDelete, ApiBlock, ApiProtect, ApiImageRotate, ApiOptions, ApiSetNotificationTimestamp, ApiFileRevert, ApiImport, ApiUndelete, ApiRollback, ApiUnblock, ApiEmailUser, ApiPatrol, ApiUserrights, and ApiWatch.

Definition at line 1546 of file ApiBase.php.

Referenced by getPossibleErrors().

ApiBase::parameterNotEmpty ( x) [private]

Callback function used in requireOnlyOneParameter to check whether required parameters are set.

Parameters:
$xobject Parameter to check is not null/false
Returns:
bool

Definition at line 802 of file ApiBase.php.

ApiBase::parseErrors ( errors)

Parses a list of errors into a standardised format.

Parameters:
array$errorsList of errors. Items can be in the for array( key, param1, param2, ... ) or array( 'code' => ..., 'info' => ... )
Returns:
array Parsed list of errors with items in the form array( 'code' => ..., 'info' => ... )

Definition at line 1667 of file ApiBase.php.

References $ret, array(), as, and parseMsg().

ApiBase::parseMsg ( error)

Return the error message related to a certain array.

Parameters:
array$errorElement of a getUserPermissionsErrors()-style array
Returns:
array('code' => code, 'info' => info)

Definition at line 1478 of file ApiBase.php.

References $error, $key, array(), and wfMsgReplaceArgs().

Referenced by ApiImageRotate\checkPermissions(), dieReadOnly(), dieUsageMsg(), dieUsageMsgOrDebug(), ApiMove\execute(), ApiPurge\execute(), ApiMove\moveSubpages(), and parseErrors().

ApiBase::parseMultiValue ( valueName,
value,
allowMultiple,
allowedValues 
) [protected]

Return an array of values that were given in a 'a|b|c' notation, after it optionally validates them against the list allowed values.

Parameters:
string$valueNameThe name of the parameter (for error reporting)
$valuemixed The value being parsed
bool$allowMultipleCan $value contain more than one value separated by '|'?
$allowedValuesmixed An array of values to check against. If null, all values are accepted.
Returns:
mixed (allowMultiple ? an_array_of_values : a_single_value)

Definition at line 1062 of file ApiBase.php.

References $s, $value, array(), dieUsage(), LIMIT_SML1, and setWarning().

Referenced by getParameterFromSettings().

Start module profiling.

Definition at line 1744 of file ApiBase.php.

References dieDebug(), getModuleProfileName(), and wfProfileIn().

Referenced by ApiQueryBase\checkRowCount(), getDB(), and ApiQueryBase\select().

Start module profiling.

Definition at line 1688 of file ApiBase.php.

References dieDebug(), getModuleProfileName(), and wfProfileIn().

End module profiling.

Definition at line 1699 of file ApiBase.php.

References dieDebug(), getModuleProfileName(), and wfProfileOut().

Referenced by safeProfileOut().

Die if more than one of a certain set of parameters is set and not false.

Parameters:
$paramsarray

Definition at line 718 of file ApiBase.php.

References $params, array(), dieUsage(), and getModulePrefix().

Referenced by ApiSetNotificationTimestamp\execute(), and ApiQueryBlocks\execute().

Die if none or more than one of a certain set of parameters is set and not false.

Parameters:
array$paramsof parameter names

Definition at line 682 of file ApiBase.php.

References $params, array(), dieUsage(), and getModulePrefix().

Referenced by ApiMove\execute(), ApiPatrol\execute(), and getTitleOrPageId().

When modules crash, sometimes it is needed to do a profileOut() regardless of the profiling state the module was in.

This method does such cleanup.

Definition at line 1716 of file ApiBase.php.

References profileDBOut(), and profileOut().

ApiBase::setWatch ( watch,
titleObj,
userOption = null 
) [protected]

Set a watch (or unwatch) based the based on a watchlist parameter.

Parameters:
string$watchValid values: 'watch', 'unwatch', 'preferences', 'nochange'
$titleObjTitle the article's title to change
string$userOptionThe user option to consider when $watch=preferences

Definition at line 862 of file ApiBase.php.

References $value, WatchAction\doWatchOrUnwatch(), ContextSource\getUser(), and getWatchlistValue().

Referenced by ApiProtect\execute(), ApiUndelete\execute(), ApiMove\execute(), ApiRollback\execute(), and ApiDelete\execute().

Indicates if this module needs maxlag to be checked.

Returns:
bool

Reimplemented in ApiQuery, and ApiHelp.

Definition at line 1513 of file ApiBase.php.

static ApiBase::truncateArray ( &$  arr,
limit 
) [static]

Truncate an array to a certain length.

Parameters:
array$arrArray to truncate
int$limitMaximum length
Returns:
bool True if the array was truncated, false otherwise

Definition at line 1193 of file ApiBase.php.

References $limit.

ApiBase::validateLimit ( paramName,
&$  value,
min,
max,
botMax = null,
enforceLimits = false 
)

Validate the value against the minimum and user/bot maximum limits.

Prints usage info on failure.

Parameters:
string$paramNameParameter name
int$valueParameter value
int | null$minMinimum value
int | null$maxMaximum value for users
int$botMaxMaximum value for sysops/bots
$enforceLimitsBoolean Whether to enforce (die) if value is outside limits

Definition at line 1115 of file ApiBase.php.

References $value, encodeParamName(), getMain(), and warnOrDie().

Referenced by ApiQueryDeletedrevs\execute(), ApiQueryRevisions\execute(), and getParameterFromSettings().

ApiBase::validateTimestamp ( value,
encParamName 
)

Validate and normalize of parameters of type 'timestamp'.

Parameters:
string$valueParameter value
string$encParamNameParameter name
Returns:
string Validated and normalized parameter

Definition at line 1151 of file ApiBase.php.

References $value, dieUsage(), and wfTimestamp().

Referenced by getParameterFromSettings().

ApiBase::validateUser ( value,
encParamName 
) [private]

Validate and normalize of parameters of type 'user'.

Parameters:
string$valueParameter value
string$encParamNameParameter name
Returns:
string Validated and normalized parameter

Definition at line 1165 of file ApiBase.php.

References $title, $value, dieUsage(), and Title\makeTitleSafe().

Referenced by getParameterFromSettings().

ApiBase::warnOrDie ( msg,
enforceLimits = false 
) [private]

Adds a warning to the output, else dies.

Parameters:
$msgString Message to show as a warning, or error message if dying
$enforceLimitsBoolean Whether this is an enforce (die)

Definition at line 1179 of file ApiBase.php.

References dieUsage(), and setWarning().

Referenced by validateLimit().


Member Data Documentation

ApiBase::$mDBTime = 0

Definition at line 1739 of file ApiBase.php.

ApiBase::$mDBTimeIn = 0 [private]

Profiling: database execution time.

Definition at line 1739 of file ApiBase.php.

ApiBase::$messageMap [static]

Array that maps message keys to error messages.

$1 and friends are replaced.

Definition at line 1260 of file ApiBase.php.

Referenced by dieStatus().

ApiBase::$mMainModule [private]

Definition at line 76 of file ApiBase.php.

ApiBase::$mModuleName

Definition at line 76 of file ApiBase.php.

ApiBase::$mModulePrefix

Definition at line 76 of file ApiBase.php.

ApiBase::$mModuleTime = 0

Definition at line 1683 of file ApiBase.php.

ApiBase::$mParamCache = array() [private]

Definition at line 78 of file ApiBase.php.

ApiBase::$mSlaveDB = null [private]

Definition at line 77 of file ApiBase.php.

ApiBase::$mTimeIn = 0 [private]

Profiling: total module execution time.

Definition at line 1683 of file ApiBase.php.

getAllowedParams() flag: When set, the result could take longer to generate, but should be more thorough.

E.g. get the list of generators for ApiSandBox extension

Since:
1.21

Definition at line 74 of file ApiBase.php.

Referenced by ApiPageSet\getAllowedParams(), and makeHelpMsgParameters().

Definition at line 46 of file ApiBase.php.

Referenced by ApiQueryFileRepoInfo\getAllowedParams(), ApiTokens\getAllowedParams(), ApiQueryStashImageInfo\getAllowedParams(), ApiExpandTemplates\getAllowedParams(), ApiQueryPagePropNames\getAllowedParams(), ApiUserrights\getAllowedParams(), ApiOpenSearch\getAllowedParams(), ApiUndelete\getAllowedParams(), ApiQueryExternalLinks\getAllowedParams(), ApiFileRevert\getAllowedParams(), ApiQueryLangLinks\getAllowedParams(), ApiQueryPagesWithProp\getAllowedParams(), ApiProtect\getAllowedParams(), ApiOptions\getAllowedParams(), ApiQueryWatchlistRaw\getAllowedParams(), ApiQueryTags\getAllowedParams(), ApiQueryIWLinks\getAllowedParams(), ApiQueryImages\getAllowedParams(), ApiQueryRandom\getAllowedParams(), ApiQueryQueryPage\getAllowedParams(), ApiQueryExtLinksUsage\getAllowedParams(), ApiFeedContributions\getAllowedParams(), ApiQueryProtectedTitles\getAllowedParams(), ApiQueryAllCategories\getAllowedParams(), ApiQueryIWBacklinks\getAllowedParams(), ApiQueryLangBacklinks\getAllowedParams(), ApiQueryDuplicateFiles\getAllowedParams(), ApiDelete\getAllowedParams(), ApiCreateAccount\getAllowedParams(), ApiMove\getAllowedParams(), ApiQueryCategories\getAllowedParams(), ApiQueryLinks\getAllowedParams(), ApiQueryUserInfo\getAllowedParams(), ApiQueryAllMessages\getAllowedParams(), ApiFeedWatchlist\getAllowedParams(), ApiQuerySearch\getAllowedParams(), ApiQueryAllPages\getAllowedParams(), ApiQueryFilearchive\getAllowedParams(), ApiQueryAllLinks\getAllowedParams(), ApiQueryORM\getAllowedParams(), ApiQueryBlocks\getAllowedParams(), ApiQueryCategoryMembers\getAllowedParams(), ApiQueryAllImages\getAllowedParams(), ApiQueryUsers\getAllowedParams(), ApiQueryDeletedrevs\getAllowedParams(), ApiQueryAllUsers\getAllowedParams(), ApiQueryWatchlist\getAllowedParams(), ApiQueryContributions\getAllowedParams(), ApiQueryLogEvents\getAllowedParams(), ApiQueryImageInfo\getAllowedParams(), ApiEditPage\getAllowedParams(), ApiQueryRecentChanges\getAllowedParams(), ApiQueryRevisions\getAllowedParams(), ApiQuerySiteinfo\getAllowedParams(), ApiUpload\getAllowedParams(), ApiQueryInfo\getAllowedParams(), getParameterFromSettings(), and makeHelpMsgParameters().

Definition at line 47 of file ApiBase.php.

Referenced by ApiQueryFileRepoInfo\getAllowedParams(), ApiTokens\getAllowedParams(), ApiQueryStashImageInfo\getAllowedParams(), ApiUserrights\getAllowedParams(), ApiOpenSearch\getAllowedParams(), ApiUndelete\getAllowedParams(), ApiQueryPageProps\getAllowedParams(), ApiQueryPagesWithProp\getAllowedParams(), ApiProtect\getAllowedParams(), ApiHelp\getAllowedParams(), ApiOptions\getAllowedParams(), ApiQueryWatchlistRaw\getAllowedParams(), ApiQueryTags\getAllowedParams(), ApiQueryImages\getAllowedParams(), ApiQueryRandom\getAllowedParams(), ApiQueryExtLinksUsage\getAllowedParams(), ApiFeedContributions\getAllowedParams(), ApiQueryProtectedTitles\getAllowedParams(), ApiQueryAllCategories\getAllowedParams(), ApiQueryIWBacklinks\getAllowedParams(), ApiQueryLangBacklinks\getAllowedParams(), ApiQueryCategories\getAllowedParams(), ApiQueryLinks\getAllowedParams(), ApiQueryUserInfo\getAllowedParams(), ApiQueryAllMessages\getAllowedParams(), ApiQuerySearch\getAllowedParams(), ApiQueryAllPages\getAllowedParams(), ApiQueryFilearchive\getAllowedParams(), ApiQueryAllLinks\getAllowedParams(), ApiQueryORM\getAllowedParams(), ApiQueryBlocks\getAllowedParams(), ApiQueryCategoryMembers\getAllowedParams(), ApiQueryAllImages\getAllowedParams(), ApiQueryUsers\getAllowedParams(), ApiQueryDeletedrevs\getAllowedParams(), ApiQueryAllUsers\getAllowedParams(), ApiQueryWatchlist\getAllowedParams(), ApiQueryContributions\getAllowedParams(), ApiQueryLogEvents\getAllowedParams(), ApiQueryImageInfo\getAllowedParams(), ApiQueryRecentChanges\getAllowedParams(), ApiQuery\getAllowedParams(), ApiQueryRevisions\getAllowedParams(), ApiQuerySiteinfo\getAllowedParams(), ApiQueryInfo\getAllowedParams(), ApiPageSet\getAllowedParams(), getParameterFromSettings(), and makeHelpMsgParameters().

const ApiBase::PARAM_MAX = 3
const ApiBase::PARAM_MIN = 5
Since:
1.17

Definition at line 57 of file ApiBase.php.

Referenced by getParameterFromSettings().

Definition at line 48 of file ApiBase.php.

Referenced by ApiQueryFileRepoInfo\getAllowedParams(), ApiTokens\getAllowedParams(), ApiPatrol\getAllowedParams(), ApiQueryStashImageInfo\getAllowedParams(), ApiExpandTemplates\getAllowedParams(), ApiQueryPagePropNames\getAllowedParams(), ApiUnblock\getAllowedParams(), ApiUserrights\getAllowedParams(), ApiEmailUser\getAllowedParams(), ApiOpenSearch\getAllowedParams(), ApiUndelete\getAllowedParams(), ApiWatch\getAllowedParams(), ApiImport\getAllowedParams(), ApiComparePages\getAllowedParams(), ApiQueryExternalLinks\getAllowedParams(), ApiFileRevert\getAllowedParams(), ApiQueryLangLinks\getAllowedParams(), ApiQueryPagesWithProp\getAllowedParams(), ApiProtect\getAllowedParams(), ApiOptions\getAllowedParams(), ApiQueryWatchlistRaw\getAllowedParams(), ApiQueryTags\getAllowedParams(), ApiQueryIWLinks\getAllowedParams(), ApiQueryImages\getAllowedParams(), ApiQueryRandom\getAllowedParams(), ApiQueryQueryPage\getAllowedParams(), ApiBlock\getAllowedParams(), ApiQueryExtLinksUsage\getAllowedParams(), ApiFeedContributions\getAllowedParams(), ApiQueryAllCategories\getAllowedParams(), ApiQueryProtectedTitles\getAllowedParams(), ApiQueryIWBacklinks\getAllowedParams(), ApiQueryLangBacklinks\getAllowedParams(), ApiQueryDuplicateFiles\getAllowedParams(), ApiCreateAccount\getAllowedParams(), ApiDelete\getAllowedParams(), ApiImageRotate\getAllowedParams(), ApiMove\getAllowedParams(), ApiQueryCategories\getAllowedParams(), ApiQueryLinks\getAllowedParams(), ApiSetNotificationTimestamp\getAllowedParams(), ApiQueryUserInfo\getAllowedParams(), ApiQueryAllMessages\getAllowedParams(), ApiFeedWatchlist\getAllowedParams(), ApiQuerySearch\getAllowedParams(), ApiQueryAllPages\getAllowedParams(), ApiQueryFilearchive\getAllowedParams(), ApiQueryAllLinks\getAllowedParams(), ApiQueryORM\getAllowedParams(), ApiQueryBlocks\getAllowedParams(), ApiQueryCategoryMembers\getAllowedParams(), ApiQueryAllImages\getAllowedParams(), ApiQueryUsers\getAllowedParams(), ApiQueryDeletedrevs\getAllowedParams(), ApiQueryAllUsers\getAllowedParams(), ApiQueryWatchlist\getAllowedParams(), ApiQueryContributions\getAllowedParams(), ApiQueryLogEvents\getAllowedParams(), ApiQueryImageInfo\getAllowedParams(), ApiEditPage\getAllowedParams(), ApiQueryRecentChanges\getAllowedParams(), ApiQuery\getAllowedParams(), ApiQueryRevisions\getAllowedParams(), ApiQuerySiteinfo\getAllowedParams(), ApiUpload\getAllowedParams(), ApiQueryInfo\getAllowedParams(), ApiPageSet\getAllowedParams(), getParameterFromSettings(), and makeHelpMsgParameters().


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