MediaWiki  master
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:

Public Member Functions

 __construct (ApiMain $mainModule, $moduleName, $modulePrefix='')
 Stable to call. More...
 
- Public Member Functions inherited from ContextSource
 canUseWikiPage ()
 Check whether a WikiPage object can be get with getWikiPage(). More...
 
 exportSession ()
 Export the resolved user IP, HTTP headers, user ID, and session ID. More...
 
 getConfig ()
 
 getContext ()
 Get the base IContextSource object. More...
 
 getLanguage ()
 
 getOutput ()
 
 getRequest ()
 
 getSkin ()
 
 getStats ()
 
 getTiming ()
 
 getTitle ()
 
 getUser ()
 Stable to override. More...
 
 getWikiPage ()
 Get the WikiPage object. More...
 
 msg ( $key,... $params)
 Get a Message object with context set Parameters are the same as wfMessage() More...
 
 setContext (IContextSource $context)
 

Public Attributes

string $mModulePrefix
 
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. More...
 
const LIMIT_BIG1 = 500
 Fast query, standard limit. More...
 
const LIMIT_BIG2 = 5000
 Fast query, apihighlimits limit. More...
 
const LIMIT_SML1 = 50
 Slow query, standard limit. More...
 
const LIMIT_SML2 = 500
 Slow query, apihighlimits limit. More...
 
Old constants for ::getAllowedParams() arrays
Deprecated:
since 1.35, use the equivalent ParamValidator or TypeDef constants instead.
const PARAM_DFLT = ParamValidator::PARAM_DEFAULT
 (boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE More...
 
const PARAM_ISMULTI = ParamValidator::PARAM_ISMULTI
 (boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE More...
 
const PARAM_TYPE = ParamValidator::PARAM_TYPE
 (boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE More...
 
const PARAM_MAX = IntegerDef::PARAM_MAX
 (boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE More...
 
const PARAM_MAX2 = IntegerDef::PARAM_MAX2
 (boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE More...
 
const PARAM_MIN = IntegerDef::PARAM_MIN
 (boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE More...
 
const PARAM_ALLOW_DUPLICATES = ParamValidator::PARAM_ALLOW_DUPLICATES
 (boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE More...
 
const PARAM_DEPRECATED = ParamValidator::PARAM_DEPRECATED
 (boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE More...
 
const PARAM_REQUIRED = ParamValidator::PARAM_REQUIRED
 (boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE More...
 
const PARAM_SUBMODULE_MAP = SubmoduleDef::PARAM_SUBMODULE_MAP
 (boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE More...
 
const PARAM_SUBMODULE_PARAM_PREFIX = SubmoduleDef::PARAM_SUBMODULE_PARAM_PREFIX
 (boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE More...
 
const PARAM_ALL = ParamValidator::PARAM_ALL
 (boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE More...
 
const PARAM_EXTRA_NAMESPACES = NamespaceDef::PARAM_EXTRA_NAMESPACES
 (boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE More...
 
const PARAM_SENSITIVE = ParamValidator::PARAM_SENSITIVE
 (boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE More...
 
const PARAM_DEPRECATED_VALUES = EnumDef::PARAM_DEPRECATED_VALUES
 (boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE More...
 
const PARAM_ISMULTI_LIMIT1 = ParamValidator::PARAM_ISMULTI_LIMIT1
 (boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE More...
 
const PARAM_ISMULTI_LIMIT2 = ParamValidator::PARAM_ISMULTI_LIMIT2
 (boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE More...
 
const PARAM_MAX_BYTES = StringDef::PARAM_MAX_BYTES
 (boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE More...
 
const PARAM_MAX_CHARS = StringDef::PARAM_MAX_CHARS
 (boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE More...
 
const PARAM_RANGE_ENFORCE = 'api-param-range-enforce'
 (boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE More...
 
API-specific constants for ::getAllowedParams() arrays
const PARAM_HELP_MSG = 'api-param-help-msg'
 (string|array|Message) Specify an alternative i18n documentation message for this parameter. More...
 
const PARAM_HELP_MSG_APPEND = 'api-param-help-msg-append'
 ((string|array|Message)[]) Specify additional i18n messages to append to the normal message for this parameter. More...
 
const PARAM_HELP_MSG_INFO = 'api-param-help-msg-info'
 (array) Specify additional information tags for the parameter. More...
 
const PARAM_VALUE_LINKS = 'api-param-value-links'
 Deprecated and unused. More...
 
const PARAM_HELP_MSG_PER_VALUE = 'api-param-help-msg-per-value'
 ((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg for ApiBase::makeMessage(). More...
 
const PARAM_TEMPLATE_VARS = 'param-template-vars'
 (array) Indicate that this is a templated parameter, and specify replacements. More...
 

Protected Member Functions

Deprecated methods
 explodeMultiValue ( $value, $limit)
 Split a multi-valued parameter string, like explode() More...
 
 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. More...
 
 validateLimit ( $name, &$value, $min, $max, $botMax=null, $enforceLimits=false)
 Validate the value against the minimum and user/bot maximum limits. More...
 
 validateTimestamp ( $value, $encParamName)
 Validate and normalize parameters of type 'timestamp'. More...
 

Private Attributes

HookContainer $hookContainer
 
ApiHookRunner $hookRunner
 
ApiMain $mMainModule
 
string $mModuleName
 
array null bool $mModuleSource = false
 
array $mParamCache = []
 
 $mReplicaDB = null
 

Static Private Attributes

static $blockMsgMap
 $var array Map of web UI block messages to corresponding API messages and codes More...
 
static array $extensionInfo = null
 Maps extension paths to info arrays. More...
 
static stdClass[][] $filterIDsCache = []
 Cache for self::filterIDs() More...
 

Methods to implement

 execute ()
 Evaluates the parameters, performs the requested query, and sets up the result. More...
 
 getModuleManager ()
 Get the module manager, or null if this module has no sub-modules. More...
 
 getCustomPrinter ()
 If the module may only be used with a certain format module, it should override this method to return an instance of that formatter. More...
 
 getHelpUrls ()
 Return links to more detailed help pages about the module. More...
 
 shouldCheckMaxlag ()
 Indicates if this module needs maxlag to be checked Stable to override. More...
 
 isReadMode ()
 Indicates whether this module requires read rights Stable to override. More...
 
 isWriteMode ()
 Indicates whether this module requires write mode. More...
 
 mustBePosted ()
 Indicates whether this module must be called with a POST request Stable to override. More...
 
 isDeprecated ()
 Indicates whether this module is deprecated. More...
 
 isInternal ()
 Indicates whether this module is "internal" Internal API modules are not (yet) intended for 3rd party use and may be unstable. More...
 
 needsToken ()
 Returns the token type this module requires in order to execute. More...
 
 getConditionalRequestData ( $condition)
 Returns data for HTTP conditional request mechanisms. More...
 
 getExamplesMessages ()
 Returns usage examples for this module. More...
 
 getAllowedParams ()
 Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (array with PARAM_* constants as keys) Don't call this function directly: use getFinalParams() to allow hooks to modify parameters as needed. More...
 
 getWebUITokenSalt (array $params)
 Fetch the salt used in the Web UI corresponding to this module. More...
 

Data access methods

 getModuleName ()
 Get the name of the module being executed by this instance. More...
 
 getModulePrefix ()
 Get parameter prefix (usually two letters or an empty string). More...
 
 getMain ()
 Get the main module. More...
 
 isMain ()
 Returns true if this module is the main module ($this === $this->mMainModule), false otherwise. More...
 
 getParent ()
 Get the parent of this module Stable to override. More...
 
 lacksSameOriginSecurity ()
 Returns true if the current request breaks the same-origin policy. More...
 
 getModulePath ()
 Get the path to this module. More...
 
 getModuleFromPath ( $path)
 Get a module from its module path. More...
 
 getResult ()
 Get the result object. More...
 
 getErrorFormatter ()
 Get the error formatter Stable to override. More...
 
 getContinuationManager ()
 Get the continuation manager. More...
 
 setContinuationManager (ApiContinuationManager $manager=null)
 Set the continuation manager. More...
 
 getDB ()
 Gets a default replica DB connection object Stable to override. More...
 
 getPermissionManager ()
 Obtain a PermissionManager instance that subclasses may use in their authorization checks. More...
 
 getHookContainer ()
 Get a HookContainer, for running extension hooks or for hook metadata. More...
 
 getHookRunner ()
 Get an ApiHookRunner for running core API hooks. More...
 

Parameter handling

 dynamicParameterDocumentation ()
 Indicate if the module supports dynamically-determined parameters that cannot be included in self::getAllowedParams(). More...
 
 encodeParamName ( $paramName)
 This method mangles parameter name based on the prefix supplied to the constructor. More...
 
 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. More...
 
 requireOnlyOneParameter ( $params,... $required)
 Die if none or more than one of a certain set of parameters is set and not false. More...
 
 requireMaxOneParameter ( $params,... $required)
 Die if more than one of a certain set of parameters is set and not false. More...
 
 requireAtLeastOneParameter ( $params,... $required)
 Die if none of a certain set of parameters is set and not false. More...
 
 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. More...
 
 getTitleOrPageId ( $params, $load=false)
 Get a WikiPage object from a title or pageid param, if possible. More...
 
 getTitleFromTitleOrPageId ( $params)
 Get a Title object from a title or pageid param, if possible. More...
 
 handleParamNormalization ( $paramName, $value, $rawValue)
 Handle when a parameter was Unicode-normalized. More...
 
 validateToken ( $token, array $params)
 Validate the supplied token. More...
 
 getParameter ( $paramName, $parseLimit=true)
 Get a value for the given parameter. More...
 
 getParameterFromSettings ( $name, $settings, $parseLimit)
 Using the settings determine the value for the given parameter. More...
 
 parameterNotEmpty ( $x)
 Callback function used in requireOnlyOneParameter to check whether required parameters are set. More...
 

Utility methods

 getWatchlistUser ( $params)
 Gets the user for whom to get the watchlist. More...
 
 errorArrayToStatus (array $errors, User $user=null)
 Turn an array of message keys or key+param arrays into a Status. More...
 
 addBlockInfoToStatus (StatusValue $status, User $user=null)
 Add block info to block messages in a Status. More...
 
 useTransactionalTimeLimit ()
 Call wfTransactionalTimeLimit() if this request was POSTed. More...
 
 filterIDs ( $fields, array $ids)
 Filter out-of-range values from a list of positive integer IDs. More...
 
static makeMessage ( $msg, IContextSource $context, array $params=null)
 Create a Message from a string or array. More...
 

Warning and error reporting

 addWarning ( $msg, $code=null, $data=null)
 Add a warning for this module. More...
 
 addDeprecation ( $msg, $feature, $data=[])
 Add a deprecation warning for this module. More...
 
 addError ( $msg, $code=null, $data=null)
 Add an error for this module without aborting. More...
 
 addMessagesFromStatus (StatusValue $status, $types=[ 'warning', 'error'], array $filter=[])
 Add warnings and/or errors from a Status. More...
 
 dieWithError ( $msg, $code=null, $data=null, $httpCode=null)
 Abort execution with an error. More...
 
 dieWithException (Throwable $exception, array $options=[])
 Abort execution with an error derived from a throwable. More...
 
 dieBlocked (AbstractBlock $block)
 Throw an ApiUsageException, which will (if uncaught) call the main module's error handler and die with an error message including block info. More...
 
 dieStatus (StatusValue $status)
 Throw an ApiUsageException based on the Status object. More...
 
 dieReadOnly ()
 Helper function for readonly errors. More...
 
 checkUserRightsAny ( $rights, $user=null)
 Helper function for permission-denied errors. More...
 
 checkTitleUserPermissions (LinkTarget $linkTarget, $actions, array $options=[])
 Helper function for permission-denied errors. More...
 
 dieWithErrorOrDebug ( $msg, $code=null, $data=null, $httpCode=null)
 Will only set a warning instead of failing if the global $wgDebugAPI is set to true. More...
 
 logFeatureUsage ( $feature)
 Write logging information for API features to a debug log, for usage analysis. More...
 
 dieContinueUsageIf ( $condition)
 Die with the 'badcontinue' error. More...
 
static dieDebug ( $method, $message)
 Internal code errors should be reported with this method. More...
 

Help message generation

 getFinalSummary ()
 Get final module summary. More...
 
 getFinalDescription ()
 Get final module description, after hooks have had a chance to tweak it as needed. More...
 
 getFinalParams ( $flags=0)
 Get final list of parameters, after hooks have had a chance to tweak it as needed. More...
 
 getFinalParamDescription ()
 Get final parameter descriptions, after hooks have had a chance to tweak it as needed. More...
 
 modifyHelp (array &$help, array $options, array &$tocData)
 Called from ApiHelp before the pieces are joined together and returned. More...
 
 getSummaryMessage ()
 Return the summary message. More...
 
 getExtendedDescription ()
 Return the extended help text message. More...
 
 getHelpFlags ()
 Generates the list of flags for the help screen and for action=paraminfo. More...
 
 getModuleSourceInfo ()
 Returns information about the source of this module, if known. More...
 

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.

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

Stable to extend

Definition at line 52 of file ApiBase.php.

Constructor & Destructor Documentation

◆ __construct()

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

Stable to call.

Parameters
ApiMain$mainModule
string$moduleNameName of this module
string$modulePrefixPrefix to use for parameter names

Reimplemented in ApiComparePages, ApiEditPage, ApiWatch, ApiDelete, ApiUpload, ApiMove, ApiRollback, ApiProtect, ApiUndelete, and ApiOpenSearchFormatJson.

Definition at line 212 of file ApiBase.php.

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

Member Function Documentation

◆ addBlockInfoToStatus()

ApiBase::addBlockInfoToStatus ( StatusValue  $status,
User  $user = null 
)

Add block info to block messages in a Status.

Since
1.33
Parameters
StatusValue$status
User | null$user

Definition at line 1220 of file ApiBase.php.

References ApiMessage\create(), ContextSource\getUser(), StatusValue\hasMessage(), and StatusValue\replaceMessage().

Referenced by dieStatus().

◆ addDeprecation()

ApiBase::addDeprecation (   $msg,
  $feature,
  $data = [] 
)

Add a deprecation warning for this module.

A combination of $this->addWarning() and $this->logFeatureUsage()

Since
1.29
Parameters
string | array | Message$msgSee ApiErrorFormatter::addWarning()
string | null$featureSee ApiBase::logFeatureUsage()
array | null$dataSee ApiErrorFormatter::addWarning()

Definition at line 1314 of file ApiBase.php.

References addWarning(), getHookRunner(), getMain(), logFeatureUsage(), and ContextSource\msg().

Referenced by ApiTokens\execute(), ApiExpandTemplates\execute(), ApiQueryDeletedrevs\execute(), ApiLogin\execute(), ApiQueryRevisionsBase\parseParameters(), and ApiMain\setupExternalResponse().

◆ addError()

ApiBase::addError (   $msg,
  $code = null,
  $data = null 
)

Add an error for this module without aborting.

If $msg is not an ApiMessage, the message code will be derived from the message key by stripping any "apiwarn-" or "apierror-" prefix.

Note
If you want to abort processing, use self::dieWithError() instead.
Since
1.29
Parameters
string | array | Message$msgSee ApiErrorFormatter::addError()
string | null$codeSee ApiErrorFormatter::addError()
array | null$dataSee ApiErrorFormatter::addError()

Definition at line 1347 of file ApiBase.php.

References getErrorFormatter(), and getModulePath().

◆ addMessagesFromStatus()

ApiBase::addMessagesFromStatus ( StatusValue  $status,
  $types = [ 'warning',
'error']  ,
array  $filter = [] 
)

Add warnings and/or errors from a Status.

Note
If you want to abort processing, use self::dieStatus() instead.
Since
1.29
Parameters
StatusValue$status
string[]$types'warning' and/or 'error'
string[]$filterMessage keys to filter out (since 1.33)

Definition at line 1360 of file ApiBase.php.

References getErrorFormatter(), and getModulePath().

Referenced by ApiDelete\execute().

◆ addWarning()

ApiBase::addWarning (   $msg,
  $code = null,
  $data = null 
)

Add a warning for this module.

Users should monitor this section to notice any changes in API. Multiple calls to this function will result in multiple warning messages.

If $msg is not an ApiMessage, the message code will be derived from the message key by stripping any "apiwarn-" or "apierror-" prefix.

Since
1.29
Parameters
string | array | Message$msgSee ApiErrorFormatter::addWarning()
string | null$codeSee ApiErrorFormatter::addWarning()
array | null$dataSee ApiErrorFormatter::addWarning()

Definition at line 1300 of file ApiBase.php.

References getErrorFormatter(), and getModulePath().

Referenced by addDeprecation(), ApiFormatXml\addXslt(), dieWithErrorOrDebug(), ApiTokens\execute(), ApiCheckToken\execute(), ApiPurge\execute(), ApiExpandTemplates\execute(), ApiQueryDisabled\execute(), ApiQueryTokens\execute(), ApiParamInfo\execute(), ApiOptions\execute(), ApiComparePages\execute(), ApiParse\execute(), ApiQueryLanguageinfo\execute(), ApiQueryUsers\execute(), ApiPageSet\executeInternal(), ApiQueryRevisionsBase\extractDeprecatedContent(), ApiQueryInfo\extractPageInfo(), extractRequestParams(), ApiQueryRecentChanges\extractRowInfo(), ApiComparePages\getDiffRevision(), ApiMain\getVal(), ApiMain\handleException(), handleParamNormalization(), ApiQueryImageInfo\mergeThumbParams(), parseMultiValue(), ApiQueryRevisionsBase\parseParameters(), ApiMain\printResult(), ApiMain\reportUnusedParams(), ApiQueryImages\run(), ApiQueryAllDeletedRevisions\run(), ApiQueryCategories\run(), ApiQueryLinks\run(), and ApiQueryRevisions\run().

◆ checkTitleUserPermissions()

ApiBase::checkTitleUserPermissions ( LinkTarget  $linkTarget,
  $actions,
array  $options = [] 
)

Helper function for permission-denied errors.

Parameters
LinkTarget$linkTarget
string | string[]$actions
array$optionsAdditional options
  • user: (User) User to use rather than $this->getUser()
  • autoblock: (bool, default false) Whether to spread autoblocks
Exceptions
ApiUsageExceptionif the user doesn't have all of the rights.
Since
1.29
1.33 Changed the third parameter from $user to $options.

Definition at line 1508 of file ApiBase.php.

References dieStatus(), errorArrayToStatus(), getPermissionManager(), and ContextSource\getUser().

Referenced by ApiImageRotate\execute(), ApiProtect\execute(), ApiFileRevert\execute(), ApiEditPage\execute(), ApiSetPageLanguage\execute(), ApiDelete\execute(), and ApiParse\execute().

◆ checkUserRightsAny()

ApiBase::checkUserRightsAny (   $rights,
  $user = null 
)

Helper function for permission-denied errors.

Since
1.29
Parameters
string | string[]$rights
User | null$user
Exceptions
ApiUsageExceptionif the user doesn't have any of the rights. The error message is based on $rights[0].

Definition at line 1483 of file ApiBase.php.

References dieWithError(), getPermissionManager(), ContextSource\getUser(), and ContextSource\msg().

Referenced by ApiChangeContentModel\execute(), ApiRevisionDelete\execute(), ApiTag\execute(), ApiSetNotificationTimestamp\execute(), ApiOptions\execute(), ApiQueryDeletedrevs\execute(), ApiWatch\execute(), ApiSetPageLanguage\execute(), ApiBlock\execute(), and getWatchlistUser().

◆ dieBlocked()

ApiBase::dieBlocked ( AbstractBlock  $block)

Throw an ApiUsageException, which will (if uncaught) call the main module's error handler and die with an error message including block info.

Since
1.27
Parameters
AbstractBlock$blockThe block used to generate the ApiUsageException
Exceptions
ApiUsageExceptionalways

Definition at line 1408 of file ApiBase.php.

References dieWithError(), MediaWiki\Block\AbstractBlock\getType(), and MediaWiki\Block\AbstractBlock\isSitewide().

Referenced by ApiUpload\checkPermissions(), ApiRevisionDelete\execute(), ApiTag\execute(), ApiUndelete\execute(), ApiEditPage\execute(), and ApiUserrights\execute().

◆ dieContinueUsageIf()

◆ dieDebug()

◆ dieReadOnly()

ApiBase::dieReadOnly ( )

Helper function for readonly errors.

Exceptions
ApiUsageExceptionalways

Definition at line 1467 of file ApiBase.php.

References dieWithError(), and wfReadOnlyReason().

Referenced by ApiMain\checkReadOnly(), and ApiEditPage\execute().

◆ dieStatus()

◆ dieWithError()

ApiBase::dieWithError (   $msg,
  $code = null,
  $data = null,
  $httpCode = null 
)

Abort execution with an error.

If $msg is not an ApiMessage, the message code will be derived from the message key by stripping any "apiwarn-" or "apierror-" prefix.

Since
1.29
Parameters
string | array | Message$msgSee ApiErrorFormatter::addError()
string | null$codeSee ApiErrorFormatter::addError()
array | null$dataSee ApiErrorFormatter::addError()
int | null$httpCodeHTTP error code to use
Exceptions
ApiUsageExceptionalways

Definition at line 1381 of file ApiBase.php.

References ApiUsageException\newWithMessage().

Referenced by ApiQuerySiteinfo\appendDbReplLagInfo(), ApiMain\checkAsserts(), ApiMain\checkBotReadOnly(), ApiMain\checkExecutePermissions(), ApiMain\checkMaxLag(), ApiQueryImageInfo\checkParameterNormalise(), ApiUpload\checkPermissions(), checkUserRightsAny(), ApiUpload\checkVerification(), ApiMain\createPrinterByName(), dieBlocked(), dieContinueUsageIf(), dieReadOnly(), dieWithErrorOrDebug(), dieWithException(), ApiCSPReport\error(), ApiValidatePassword\execute(), ApiChangeContentModel\execute(), ApiManageTags\execute(), ApiEmailUser\execute(), ApiImport\execute(), ApiMergeHistory\execute(), ApiLogout\execute(), ApiQueryExternalLinks\execute(), ApiRevisionDelete\execute(), ApiExpandTemplates\execute(), ApiQueryMyStashedFiles\execute(), ApiDisabled\execute(), ApiFormatPhp\execute(), ApiQueryLangLinks\execute(), ApiQueryStashImageInfo\execute(), ApiOpenSearchFormatJson\execute(), ApiSetNotificationTimestamp\execute(), ApiPatrol\execute(), ApiQueryAllMessages\execute(), ApiChangeAuthenticationData\execute(), ApiProtect\execute(), ApiQueryIWLinks\execute(), ApiUndelete\execute(), ApiQueryBlocks\execute(), ApiOptions\execute(), ApiStashEdit\execute(), ApiQueryFilearchive\execute(), ApiMove\execute(), ApiUpload\execute(), ApiQueryDeletedrevs\execute(), ApiQueryImageInfo\execute(), ApiFeedRecentChanges\execute(), ApiQueryLogEvents\execute(), ApiWatch\execute(), ApiQueryUserContribs\execute(), ApiRemoveAuthenticationData\execute(), ApiSetPageLanguage\execute(), ApiEditPage\execute(), ApiDelete\execute(), ApiFeedWatchlist\execute(), ApiFeedContributions\execute(), ApiLinkAccount\execute(), ApiUserrights\execute(), ApiAMCreateAccount\execute(), ApiClientLogin\execute(), ApiResetPassword\execute(), ApiComparePages\execute(), ApiUnblock\execute(), ApiBlock\execute(), ApiParse\execute(), ApiQueryAllPages\executeGenerator(), ApiQueryAllImages\executeGenerator(), ApiPageSet\executeInternal(), ApiQueryRevisionsBase\extractAllSlotInfo(), ApiUpload\getChunkResult(), ApiParse\getContentParserOutput(), ApiUpload\getContextResult(), ApiComparePages\getDiffRevision(), ApiFeedRecentChanges\getFeedObject(), getModuleFromPath(), ApiParse\getPageParserOutput(), ApiParse\getParsedContent(), ApiRollback\getRbTitle(), ApiParse\getSectionContent(), getTitleFromTitleOrPageId(), getTitleOrPageId(), getWatchlistUser(), ApiQueryImageInfo\mergeThumbParams(), ApiQuery\outputGeneralPageInfo(), parseMultiValue(), ApiQueryRevisionsBase\parseParameters(), ApiQueryBase\parsePrefixedTitlePart(), ApiUpload\performUpload(), ApiQueryUserContribs\prepareQuery(), ApiQueryBlocks\prepareUsername(), requireAtLeastOneParameter(), requireMaxOneParameter(), requireOnlyOneParameter(), requirePostedParameters(), ApiQueryDeletedRevisions\run(), ApiQueryAllDeletedRevisions\run(), ApiQueryExtLinksUsage\run(), ApiQueryLangBacklinks\run(), ApiQueryIWBacklinks\run(), ApiQueryCategories\run(), ApiQueryWatchlistRaw\run(), ApiQuerySearch\run(), ApiQueryAllPages\run(), ApiQueryCategoryMembers\run(), ApiQueryWatchlist\run(), ApiQueryAllImages\run(), ApiQueryRevisions\run(), ApiQueryQueryPage\run(), ApiQueryBacklinksprop\run(), ApiQueryAllLinks\run(), ApiQueryRecentChanges\run(), ApiUpload\selectUploadModule(), ApiMain\setupExternalResponse(), ApiMain\setupModule(), ApiQueryBase\titlePartToKey(), ApiFileRevert\validateParameters(), and ApiUpload\verifyUpload().

◆ dieWithErrorOrDebug()

ApiBase::dieWithErrorOrDebug (   $msg,
  $code = null,
  $data = null,
  $httpCode = null 
)

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

Otherwise behaves exactly as self::dieWithError().

Since
1.29
Parameters
string | array | Message$msg
string | null$code
array | null$data
int | null$httpCode
Exceptions
ApiUsageException

Definition at line 1543 of file ApiBase.php.

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

Referenced by ApiQuery\instantiateModules(), and ApiMain\setupExternalResponse().

◆ dieWithException()

ApiBase::dieWithException ( Throwable  $exception,
array  $options = [] 
)

Abort execution with an error derived from a throwable.

Since
1.29
Parameters
Throwable$exceptionSee ApiErrorFormatter::getMessageFromException()
array$optionsSee ApiErrorFormatter::getMessageFromException()
Exceptions
ApiUsageExceptionalways

Definition at line 1393 of file ApiBase.php.

References dieWithError(), and getErrorFormatter().

Referenced by ApiImport\execute(), ApiQueryStashImageInfo\execute(), ApiStashEdit\execute(), ApiEditPage\execute(), ApiParse\execute(), and ApiComparePages\getDiffRevision().

◆ dynamicParameterDocumentation()

ApiBase::dynamicParameterDocumentation ( )

Indicate if the module supports dynamically-determined parameters that cannot be included in self::getAllowedParams().

Stable to override

Returns
string|array|Message|null Return null if the module does not support additional dynamic parameters, otherwise return a message describing them.

Reimplemented in ApiAMCreateAccount, ApiClientLogin, ApiLinkAccount, and ApiChangeAuthenticationData.

Definition at line 683 of file ApiBase.php.

◆ encodeParamName()

◆ errorArrayToStatus()

ApiBase::errorArrayToStatus ( array  $errors,
User  $user = null 
)

Turn an array of message keys or key+param arrays into a Status.

Since
1.29
Parameters
array$errors
User | null$user
Returns
Status

Definition at line 1192 of file ApiBase.php.

References ApiMessage\create(), ContextSource\getUser(), and StatusValue\newGood().

Referenced by checkTitleUserPermissions(), ApiChangeContentModel\execute(), ApiPatrol\execute(), ApiRollback\execute(), and ApiQueryInfo\extractPageInfo().

◆ execute()

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 ApiMain, ApiQueryInfo, ApiQuery, ApiPageSet, ApiQueryRecentChanges, ApiQueryBacklinks, ApiQueryUsers, ApiQueryLanguageinfo, ApiFormatFeedWrapper, ApiParse, ApiFormatRaw, ApiBlock, ApiOpenSearch, ApiQueryAllLinks, ApiQueryBacklinksprop, ApiLogin, ApiUnblock, ApiQueryRevisionsBase, ApiQueryLinks, ApiFormatJson, ApiQueryAllImages, ApiComparePages, ApiResetPassword, ApiClientLogin, ApiQueryQueryPage, ApiAMCreateAccount, ApiLinkAccount, ApiUserrights, ApiFeedContributions, ApiFeedWatchlist, ApiRollback, ApiDelete, ApiEditPage, ApiQueryContributors, ApiQueryUserContribs, ApiRemoveAuthenticationData, ApiSetPageLanguage, ApiQueryAllUsers, ApiWatch, ApiQueryLogEvents, ApiQueryFileRepoInfo, ApiQueryUserInfo, ApiCSPReport, ApiFeedRecentChanges, ApiQueryImageInfo, ApiQueryDeletedrevs, ApiFormatXml, ApiQueryWatchlist, ApiUpload, ApiMove, ApiQueryFilearchive, ApiQueryPagePropNames, ApiOptions, ApiParamInfo, ApiQueryBlocks, ApiStashEdit, ApiFileRevert, ApiQueryAuthManagerInfo, ApiQuerySearch, ApiQueryWatchlistRaw, ApiChangeAuthenticationData, ApiProtect, ApiQueryIWLinks, ApiQuerySiteinfo, ApiQueryTokens, ApiUndelete, ApiFormatPhp, ApiOpenSearchFormatJson, ApiPatrol, ApiQueryAllMessages, ApiQueryDuplicateFiles, ApiQueryIWBacklinks, ApiQueryLangBacklinks, ApiQueryLangLinks, ApiQueryPageProps, ApiQueryPagesWithProp, ApiQueryPrefixSearch, ApiQueryStashImageInfo, ApiSetNotificationTimestamp, ApiDisabled, ApiHelp, ApiQueryAllCategories, ApiQueryAllPages, ApiQueryCategoryInfo, ApiQueryDisabled, ApiQueryImages, ApiQueryMyStashedFiles, ApiTag, ApiExpandTemplates, ApiFormatNone, ApiQueryCategories, ApiQueryCategoryMembers, ApiQueryExternalLinks, ApiQueryProtectedTitles, ApiQueryRandom, ApiQueryTags, ApiRevisionDelete, ApiLogout, ApiPurge, ApiQueryExtLinksUsage, ApiRsd, ApiCheckToken, ApiClearHasMsg, ApiMergeHistory, ApiImport, ApiEmailUser, ApiImageRotate, ApiTokens, ApiManageTags, ApiChangeContentModel, and ApiValidatePassword.

◆ explodeMultiValue()

ApiBase::explodeMultiValue (   $value,
  $limit 
)
protected

Split a multi-valued parameter string, like explode()

Since
1.28
Deprecated:
since 1.35, use ParamValidator::explodeMultiValue() instead
Parameters
string$value
int$limit
Returns
string[]

Definition at line 2014 of file ApiBase.php.

References wfDeprecated().

Referenced by parseMultiValue().

◆ extractRequestParams()

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

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
bool | array$optionsIf a boolean, uses that as the value for 'parseLimit'
  • parseLimit: (bool, default true) Whether to parse the 'max' value for limit types
  • safeMode: (bool, default false) If true, avoid throwing for parameter validation errors. Returned parameter values might be ApiUsageException instances.
Returns
array

Definition at line 716 of file ApiBase.php.

References addWarning(), encodeParamName(), getFinalParams(), getParameterFromSettings(), PARAM_TEMPLATE_VARS, and wfEscapeWikiText().

Referenced by ApiAuthManagerHelper\__construct(), ApiPageSet\__construct(), ApiQuerySiteinfo\appendInterwikiMap(), ApiQuerySiteinfo\appendLanguages(), ApiValidatePassword\execute(), ApiChangeContentModel\execute(), ApiManageTags\execute(), ApiImageRotate\execute(), ApiTokens\execute(), ApiEmailUser\execute(), ApiImport\execute(), ApiCheckToken\execute(), ApiMergeHistory\execute(), ApiPurge\execute(), ApiQueryTags\execute(), ApiRevisionDelete\execute(), ApiExpandTemplates\execute(), ApiQueryExternalLinks\execute(), ApiQueryMyStashedFiles\execute(), ApiHelp\execute(), ApiTag\execute(), ApiQueryCategoryInfo\execute(), ApiPatrol\execute(), ApiQueryLangLinks\execute(), ApiQueryPageProps\execute(), ApiFormatPhp\execute(), ApiQueryStashImageInfo\execute(), ApiQueryAllMessages\execute(), ApiSetNotificationTimestamp\execute(), ApiQueryIWLinks\execute(), ApiProtect\execute(), ApiQuerySiteinfo\execute(), ApiQueryTokens\execute(), ApiUndelete\execute(), ApiFileRevert\execute(), ApiQueryAuthManagerInfo\execute(), ApiOptions\execute(), ApiParamInfo\execute(), ApiStashEdit\execute(), ApiQueryBlocks\execute(), ApiQueryFilearchive\execute(), ApiMove\execute(), ApiQueryPagePropNames\execute(), ApiFormatXml\execute(), ApiUpload\execute(), ApiQueryDeletedrevs\execute(), ApiQueryImageInfo\execute(), ApiFeedRecentChanges\execute(), ApiQueryFileRepoInfo\execute(), ApiQueryUserInfo\execute(), ApiQueryLogEvents\execute(), ApiQueryAllUsers\execute(), ApiWatch\execute(), ApiSetPageLanguage\execute(), ApiRemoveAuthenticationData\execute(), ApiEditPage\execute(), ApiQueryContributors\execute(), ApiQueryUserContribs\execute(), ApiDelete\execute(), ApiFeedWatchlist\execute(), ApiRollback\execute(), ApiFeedContributions\execute(), ApiUserrights\execute(), ApiAMCreateAccount\execute(), ApiLinkAccount\execute(), ApiClientLogin\execute(), ApiComparePages\execute(), ApiResetPassword\execute(), ApiFormatJson\execute(), ApiUnblock\execute(), ApiLogin\execute(), ApiOpenSearch\execute(), ApiBlock\execute(), ApiParse\execute(), ApiQueryUsers\execute(), ApiQuery\execute(), ApiQueryInfo\execute(), ApiHelp\getCustomPrinter(), ApiOpenSearch\getFormat(), ApiFormatJson\getMimeType(), getParameter(), ApiComparePages\guessModel(), ApiComparePages\guessTitle(), ApiQuery\isReadMode(), ApiQueryDeletedRevisions\run(), ApiQueryAllRevisions\run(), ApiQueryAllDeletedRevisions\run(), ApiQueryImages\run(), ApiQueryProtectedTitles\run(), ApiQueryPrefixSearch\run(), ApiQueryLangBacklinks\run(), ApiQueryExtLinksUsage\run(), ApiQueryIWBacklinks\run(), ApiQueryCategories\run(), ApiQueryAllCategories\run(), ApiQuerySearch\run(), ApiQueryWatchlistRaw\run(), ApiQueryDuplicateFiles\run(), ApiQueryPagesWithProp\run(), ApiQueryAllPages\run(), ApiQueryCategoryMembers\run(), ApiQueryWatchlist\run(), ApiQueryLinks\run(), ApiQueryAllImages\run(), ApiQueryRevisions\run(), ApiQueryQueryPage\run(), ApiQueryBacklinksprop\run(), ApiQueryAllLinks\run(), ApiQueryRandom\run(), ApiQueryRecentChanges\run(), ApiQueryRandom\runQuery(), and ApiMain\setupExecuteAction().

◆ filterIDs()

ApiBase::filterIDs (   $fields,
array  $ids 
)
protected

Filter out-of-range values from a list of positive integer IDs.

Since
1.33
Parameters
array$fieldsArray of pairs of table and field to check
(string|int)[]$ids IDs to filter. Strings in the array are expected to be stringified ints.
Returns
(string|int)[] Filtered IDs.

Definition at line 1252 of file ApiBase.php.

References getDB().

Referenced by ApiQueryBase\addWhereIDsFld(), ApiPageSet\initFromPageIds(), and ApiPageSet\initFromRevIDs().

◆ getAllowedParams()

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.

Stable to override

Returns
array

Reimplemented in ApiMain, ApiQueryInfo, ApiUpload, ApiQuerySiteinfo, ApiParse, ApiQueryRecentChanges, ApiQueryRevisionsBase, ApiQueryImageInfo, ApiHelp, ApiComparePages, ApiEditPage, ApiQueryUserContribs, ApiQueryBacklinks, ApiQueryRevisions, ApiQueryDeletedrevs, ApiQueryWatchlist, ApiQueryAllDeletedRevisions, ApiParamInfo, ApiQueryUsers, ApiQueryBacklinksprop, ApiFormatBase, ApiQuerySearch, ApiQueryBlocks, ApiQueryAllImages, ApiQueryUserInfo, ApiQueryCategoryMembers, ApiFormatXml, ApiOpenSearch, ApiQueryAllRevisions, ApiQueryDeletedRevisions, ApiQueryAllPages, ApiQueryAllLinks, ApiCSPReport, ApiLogin, ApiMove, ApiQueryFilearchive, ApiQueryLanguageinfo, ApiDelete, ApiOptions, ApiFeedContributions, ApiQueryAllMessages, ApiQueryExtLinksUsage, ApiBlock, ApiQueryLinks, ApiExpandTemplates, ApiQueryProtectedTitles, ApiQueryRandom, ApiStashEdit, ApiQueryCategories, ApiTag, ApiQueryIWBacklinks, ApiQueryLangBacklinks, ApiQueryQueryPage, ApiQueryDuplicateFiles, ApiQueryWatchlistRaw, ApiRevisionDelete, ApiQueryAllCategories, ApiQueryIWLinks, ApiProtect, ApiQueryExternalLinks, ApiQueryLangLinks, ApiImport, ApiQueryImages, ApiQueryPagesWithProp, ApiUnblock, ApiQueryTags, ApiRollback, ApiFeedRecentChanges, ApiFormatJson, ApiQueryMyStashedFiles, ApiClientLogin, ApiUndelete, ApiAMCreateAccount, ApiLinkAccount, ApiSetPageLanguage, ApiQueryTokens, ApiFileRevert, ApiQueryStashImageInfo, ApiMergeHistory, ApiQueryPrefixSearch, ApiQueryPageProps, ApiManageTags, ApiQueryAuthManagerInfo, ApiQueryCategoryInfo, ApiResetPassword, ApiRemoveAuthenticationData, ApiTokens, ApiPatrol, ApiEmailUser, ApiQueryPagePropNames, ApiChangeContentModel, ApiQueryFileRepoInfo, ApiChangeAuthenticationData, ApiFormatPhp, ApiCheckToken, ApiValidatePassword, and ApiQueryDisabled.

Definition at line 308 of file ApiBase.php.

Referenced by getFinalParams().

◆ getConditionalRequestData()

ApiBase::getConditionalRequestData (   $condition)

Returns data for HTTP conditional request mechanisms.

Since
1.26 Stable to override
Parameters
string$conditionCondition being queried:
  • last-modified: Return a timestamp representing the maximum of the last-modified dates for all resources involved in the request. See RFC 7232 § 2.2 for semantics.
  • etag: Return an entity-tag representing the state of all resources involved in the request. Quotes must be included. See RFC 7232 § 2.3 for semantics.
Returns
string|bool|null As described above, or null if no value is available.

Definition at line 428 of file ApiBase.php.

◆ getContinuationManager()

ApiBase::getContinuationManager ( )

Get the continuation manager.

Returns
ApiContinuationManager|null

Reimplemented in ApiMain.

Definition at line 606 of file ApiBase.php.

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

Referenced by ApiQueryAllRevisions\run(), ApiQueryRandom\run(), ApiQueryRecentChanges\run(), ApiQueryGeneratorBase\setContinueEnumParameter(), and ApiQueryBase\setContinueEnumParameter().

◆ getCustomPrinter()

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

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

Note
Do not use this just because you don't want to support non-json formats. This should be used only when there is a fundamental requirement for a specific format. Stable to override
Returns
mixed Instance of a derived class of ApiFormatBase, or null

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

Definition at line 265 of file ApiBase.php.

◆ getDB()

ApiBase::getDB ( )
protected

Gets a default replica DB connection object Stable to override.

Returns
IDatabase

Reimplemented in ApiPageSet, ApiQueryBase, and ApiQueryAllImages.

Definition at line 594 of file ApiBase.php.

References $mReplicaDB, DB_REPLICA, and wfGetDB().

Referenced by ApiQuery\doExport(), filterIDs(), ApiParse\formatCategoryLinks(), ApiComparePages\getRevisionById(), and ApiOpenSearch\search().

◆ getErrorFormatter()

◆ getExamplesMessages()

ApiBase::getExamplesMessages ( )
protected

Returns usage examples for this module.

Return value has query strings as keys, with values being either strings (message key), arrays (message key + parameter), or Message objects.

Do not call this base class implementation when overriding this method.

Since
1.25 Stable to override
Returns
array

Reimplemented in ApiMain, ApiQueryInfo, ApiUpload, ApiParse, ApiQuerySiteinfo, ApiQueryRecentChanges, ApiQueryImageInfo, ApiComparePages, ApiEditPage, ApiHelp, ApiQueryUserContribs, ApiQueryBacklinks, ApiQuery, ApiQueryRevisions, ApiQueryWatchlist, ApiQueryDeletedrevs, ApiQueryLogEvents, ApiQueryAllDeletedRevisions, ApiParamInfo, ApiQueryBacklinksprop, ApiQuerySearch, ApiQueryAllImages, ApiQueryBlocks, ApiQueryUsers, ApiQueryAllUsers, ApiQueryCategoryMembers, ApiFormatBase, ApiQueryUserInfo, ApiQueryAllPages, ApiQueryAllRevisions, ApiOpenSearch, ApiQueryAllLinks, ApiQueryDeletedRevisions, ApiFeedWatchlist, ApiQueryFilearchive, ApiMove, ApiQueryExtLinksUsage, ApiLogin, ApiQueryContributors, ApiQueryLanguageinfo, ApiFeedContributions, ApiDelete, ApiQueryAllMessages, ApiOptions, ApiBlock, ApiSetNotificationTimestamp, ApiQueryProtectedTitles, ApiQueryLinks, ApiUserrights, ApiQueryCategories, ApiExpandTemplates, ApiTag, ApiQueryRandom, ApiQueryIWBacklinks, ApiQueryLangBacklinks, ApiQueryWatchlistRaw, ApiRollback, ApiWatch, ApiImageRotate, ApiQueryAllCategories, ApiQueryQueryPage, ApiRevisionDelete, ApiQueryIWLinks, ApiProtect, ApiQueryLangLinks, ApiQueryDuplicateFiles, ApiFeedRecentChanges, ApiImport, ApiQueryExternalLinks, ApiQueryPagesWithProp, ApiQueryImages, ApiUnblock, ApiQueryTags, ApiPurge, ApiQueryStashImageInfo, ApiUndelete, ApiQueryMyStashedFiles, ApiSetPageLanguage, ApiChangeContentModel, ApiAMCreateAccount, ApiFileRevert, ApiMergeHistory, ApiManageTags, ApiClientLogin, ApiResetPassword, ApiLinkAccount, ApiQueryPrefixSearch, ApiQueryTokens, ApiQueryAuthManagerInfo, ApiQueryFileRepoInfo, ApiQueryPageProps, ApiPatrol, ApiQueryCategoryInfo, ApiEmailUser, ApiTokens, ApiRemoveAuthenticationData, ApiQueryPagePropNames, ApiChangeAuthenticationData, ApiCheckToken, ApiLogout, ApiValidatePassword, ApiRsd, and ApiClearHasMsg.

Definition at line 281 of file ApiBase.php.

◆ getExtendedDescription()

ApiBase::getExtendedDescription ( )
protected

Return the extended help text message.

This is additional text to display at the top of the help section, below the summary.

Since
1.30 Stable to override
Returns
string|array|Message

Reimplemented in ApiDisabled, ApiQueryDisabled, ApiResetPassword, ApiLogin, and ApiSetPageLanguage.

Definition at line 1644 of file ApiBase.php.

Referenced by getFinalDescription().

◆ getFinalDescription()

ApiBase::getFinalDescription ( )

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

Since
1.25, returns Message[] rather than string[]
Returns
Message[]

Reimplemented in ApiClientLogin, ApiAMCreateAccount, and ApiLinkAccount.

Definition at line 1674 of file ApiBase.php.

References ContextSource\getContext(), getExtendedDescription(), getHookRunner(), getModuleName(), getModulePath(), getModulePrefix(), getSummaryMessage(), and makeMessage().

◆ getFinalParamDescription()

ApiBase::getFinalParamDescription ( )

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

Since
1.25, returns array of Message[] rather than array of string[]
Returns
array Keys are parameter names, values are arrays of Message objects

Definition at line 1734 of file ApiBase.php.

References $path, dieDebug(), ContextSource\getContext(), getFinalParams(), getHookRunner(), getModuleFromPath(), getModuleManager(), getModuleName(), getModulePath(), getModulePrefix(), isMain(), makeMessage(), ContextSource\msg(), PARAM_DEPRECATED_VALUES, PARAM_HELP_MSG, PARAM_HELP_MSG_PER_VALUE, and PARAM_SUBMODULE_MAP.

◆ getFinalParams()

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 1703 of file ApiBase.php.

References getAllowedParams(), getHookRunner(), and needsToken().

Referenced by extractRequestParams(), and getFinalParamDescription().

◆ getFinalSummary()

ApiBase::getFinalSummary ( )

Get final module summary.

Since
1.30 Stable to override
Returns
Message

Definition at line 1658 of file ApiBase.php.

References ContextSource\getContext(), getModuleName(), getModulePath(), getModulePrefix(), getSummaryMessage(), and makeMessage().

◆ getHelpFlags()

ApiBase::getHelpFlags ( )
protected

Generates the list of flags for the help screen and for action=paraminfo.

Corresponding messages: api-help-flag-deprecated, api-help-flag-internal, api-help-flag-readrights, api-help-flag-writerights, api-help-flag-mustbeposted

Returns
string[]

Reimplemented in ApiQueryGeneratorBase.

Definition at line 1880 of file ApiBase.php.

References isDeprecated(), isInternal(), isReadMode(), isWriteMode(), and mustBePosted().

◆ getHelpUrls()

ApiBase::getHelpUrls ( )

Return links to more detailed help pages about the module.

Since
1.25, returning boolean false is deprecated Stable to override
Returns
string|array

Reimplemented in ApiQueryInfo, ApiUpload, ApiParse, ApiQuerySiteinfo, ApiQueryRecentChanges, ApiQueryImageInfo, ApiEditPage, ApiHelp, ApiQueryUserContribs, ApiQueryBacklinks, ApiQueryRevisions, ApiQuery, ApiQueryWatchlist, ApiQueryDeletedrevs, ApiQueryLogEvents, ApiQueryAllDeletedRevisions, ApiQueryBacklinksprop, ApiParamInfo, ApiQueryAllImages, ApiQuerySearch, ApiQueryBlocks, ApiQueryUsers, ApiQueryAllUsers, ApiQueryCategoryMembers, ApiFormatBase, ApiQueryUserInfo, ApiQueryAllPages, ApiQueryAllRevisions, ApiQueryAllLinks, ApiOpenSearch, ApiQueryDeletedRevisions, ApiFeedWatchlist, ApiQueryFilearchive, ApiMove, ApiQueryExtLinksUsage, ApiLogin, ApiQueryContributors, ApiDelete, ApiQueryAllMessages, ApiBlock, ApiSetNotificationTimestamp, ApiQueryProtectedTitles, ApiOptions, ApiQueryLinks, ApiUserrights, ApiQueryCategories, ApiExpandTemplates, ApiWatch, ApiTag, ApiQueryRandom, ApiQueryIWBacklinks, ApiQueryLangBacklinks, ApiQueryWatchlistRaw, ApiRollback, ApiProtect, ApiRevisionDelete, ApiQueryAllCategories, ApiQueryQueryPage, ApiQueryIWLinks, ApiQueryLangLinks, ApiQueryDuplicateFiles, ApiImport, ApiQueryExternalLinks, ApiQueryPagesWithProp, ApiQueryImages, ApiUnblock, ApiQueryTags, ApiPurge, ApiQueryStashImageInfo, ApiUndelete, ApiQueryMyStashedFiles, ApiSetPageLanguage, ApiManageTags, ApiMergeHistory, ApiResetPassword, ApiQueryTokens, ApiAMCreateAccount, ApiClientLogin, ApiQueryAuthManagerInfo, ApiLinkAccount, ApiQueryPrefixSearch, ApiChangeContentModel, ApiQueryFileRepoInfo, ApiQueryPageProps, ApiPatrol, ApiQueryCategoryInfo, ApiEmailUser, ApiRemoveAuthenticationData, ApiQueryPagePropNames, ApiChangeAuthenticationData, ApiLogout, ApiValidatePassword, and ApiClearHasMsg.

Definition at line 291 of file ApiBase.php.

◆ getHookContainer()

ApiBase::getHookContainer ( )
protected

Get a HookContainer, for running extension hooks or for hook metadata.

Since
1.35
Returns
HookContainer

Definition at line 646 of file ApiBase.php.

References $hookContainer.

Referenced by getHookRunner().

◆ getHookRunner()

◆ getMain()

ApiBase::getMain ( )

Get the main module.

Returns
ApiMain

Definition at line 459 of file ApiBase.php.

References $mMainModule.

Referenced by ApiFormatJson\__construct(), ApiFormatBase\__construct(), ApiContinuationManager\__construct(), ApiQueryBase\__construct(), ApiPageSet\__construct(), addDeprecation(), ApiFormatBase\closePrinter(), ApiExpandTemplates\execute(), ApiHelp\execute(), ApiParamInfo\execute(), ApiUpload\execute(), ApiQueryDeletedrevs\execute(), ApiFeedRecentChanges\execute(), ApiEditPage\execute(), ApiFeedWatchlist\execute(), ApiComparePages\execute(), ApiOpenSearch\execute(), ApiParse\execute(), ApiQuery\execute(), ApiPageSet\executeInternal(), ApiQueryInfo\extractPageInfo(), ApiParamInfo\getAllowedParams(), ApiUpload\getChunkResult(), getContinuationManager(), ApiQueryUserInfo\getCurrentUserInfo(), ApiFeedRecentChanges\getCustomPrinter(), ApiFeedWatchlist\getCustomPrinter(), ApiFeedContributions\getCustomPrinter(), ApiRsd\getCustomPrinter(), ApiOpenSearch\getCustomPrinter(), ApiQuery\getCustomPrinter(), ApiHelp\getCustomPrinter(), getErrorFormatter(), ApiPageSet\getGenerators(), getModuleFromPath(), getParameterFromSettings(), getParent(), getResult(), ApiFeedWatchlist\getWatchlistModule(), ApiFormatRaw\initPrinter(), ApiFormatBase\initPrinter(), lacksSameOriginSecurity(), logFeatureUsage(), ApiQueryRevisionsBase\parseParameters(), requirePostedParameters(), ApiQuerySearch\run(), ApiQueryRandom\run(), ApiUpload\selectUploadModule(), setContinuationManager(), ApiFormatBase\setHttpStatus(), ApiComparePages\setVals(), validateLimit(), and validateTimestamp().

◆ getModuleFromPath()

ApiBase::getModuleFromPath (   $path)

Get a module from its module path.

Since
1.25
Parameters
string$path
Returns
ApiBase|null
Exceptions
ApiUsageException

Definition at line 526 of file ApiBase.php.

References $path, dieWithError(), getMain(), and wfEscapeWikiText().

Referenced by ApiHelp\execute(), ApiParamInfo\execute(), and getFinalParamDescription().

◆ getModuleManager()

ApiBase::getModuleManager ( )

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

Since
1.21 Stable to override
Returns
ApiModuleManager

Reimplemented in ApiMain, and ApiQuery.

Definition at line 251 of file ApiBase.php.

Referenced by ApiFormatBase\closePrinter(), ApiParamInfo\execute(), getFinalParamDescription(), MediaWiki\Api\Validator\SubmoduleDef\getSubmoduleMap(), and ApiParamInfo\listAllSubmodules().

◆ getModuleName()

ApiBase::getModuleName ( )

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

Returns
string

Definition at line 443 of file ApiBase.php.

References $mModuleName.

Referenced by ApiPageSet\__construct(), ApiContinuationManager\addContinueParam(), ApiContinuationManager\addGeneratorContinueParam(), ApiContinuationManager\addGeneratorNonContinueParam(), ApiQuerySearch\addInterwikiResults(), ApiQueryBase\addPageSubItem(), ApiQueryBase\addPageSubItems(), ApiValidatePassword\execute(), ApiChangeContentModel\execute(), ApiManageTags\execute(), ApiEmailUser\execute(), ApiTokens\execute(), ApiImageRotate\execute(), ApiImport\execute(), ApiCheckToken\execute(), ApiClearHasMsg\execute(), ApiMergeHistory\execute(), ApiPurge\execute(), ApiQueryTags\execute(), ApiExpandTemplates\execute(), ApiRevisionDelete\execute(), ApiQueryMyStashedFiles\execute(), ApiDisabled\execute(), ApiTag\execute(), ApiHelp\execute(), ApiQueryDisabled\execute(), ApiPatrol\execute(), ApiQueryStashImageInfo\execute(), ApiQueryAllMessages\execute(), ApiSetNotificationTimestamp\execute(), ApiProtect\execute(), ApiQueryTokens\execute(), ApiUndelete\execute(), ApiFileRevert\execute(), ApiQueryAuthManagerInfo\execute(), ApiOptions\execute(), ApiParamInfo\execute(), ApiStashEdit\execute(), ApiQueryBlocks\execute(), ApiQueryPagePropNames\execute(), ApiQueryFilearchive\execute(), ApiMove\execute(), ApiUpload\execute(), ApiQueryDeletedrevs\execute(), ApiCSPReport\execute(), ApiQueryUserInfo\execute(), ApiQueryLogEvents\execute(), ApiQueryAllUsers\execute(), ApiWatch\execute(), ApiQueryUserContribs\execute(), ApiEditPage\execute(), ApiRemoveAuthenticationData\execute(), ApiSetPageLanguage\execute(), ApiDelete\execute(), ApiRollback\execute(), ApiUserrights\execute(), ApiComparePages\execute(), ApiUnblock\execute(), ApiBlock\execute(), ApiParse\execute(), ApiQueryLanguageinfo\execute(), ApiQueryUsers\execute(), ApiQueryBacklinksprop\getAllowedParams(), ApiRemoveAuthenticationData\getExamplesMessages(), ApiQueryLinks\getExamplesMessages(), ApiQueryLanguageinfo\getExamplesMessages(), ApiQueryAllLinks\getExamplesMessages(), ApiFormatBase\getExamplesMessages(), ApiQueryBacklinksprop\getExamplesMessages(), ApiAMCreateAccount\getFinalDescription(), ApiLinkAccount\getFinalDescription(), ApiClientLogin\getFinalDescription(), getFinalDescription(), getFinalParamDescription(), getFinalSummary(), ApiQueryAllLinks\getHelpUrls(), ApiQueryBacklinksprop\getHelpUrls(), getModulePath(), getParameterFromSettings(), ApiAuthManagerHelper\logAuthenticationResult(), ApiQueryRevisionsBase\parseParameters(), ApiQueryAllRevisions\run(), ApiQueryAllDeletedRevisions\run(), ApiQueryProtectedTitles\run(), ApiQueryPrefixSearch\run(), ApiQueryExtLinksUsage\run(), ApiQueryIWBacklinks\run(), ApiQueryLangBacklinks\run(), ApiQuerySearch\run(), ApiQueryWatchlistRaw\run(), ApiQueryAllCategories\run(), ApiQueryPagesWithProp\run(), ApiQueryAllPages\run(), ApiQueryCategoryMembers\run(), ApiQueryWatchlist\run(), ApiQueryAllImages\run(), ApiQueryQueryPage\run(), ApiQueryBacklinksprop\run(), ApiQueryAllLinks\run(), ApiQueryRandom\run(), ApiQueryRecentChanges\run(), ApiQueryRandom\runQuery(), and ApiUpload\selectUploadModule().

◆ getModulePath()

◆ getModulePrefix()

◆ getModuleSourceInfo()

ApiBase::getModuleSourceInfo ( )
protected

Returns information about the source of this module, if known.

Returned array is an array with the following keys:

  • path: Install path
  • name: Extension name, or "MediaWiki" for core
  • namemsg: (optional) i18n message key for a display name
  • license-name: (optional) Name of license
Returns
array|null

Definition at line 1913 of file ApiBase.php.

References $ext, $IP, $mModuleSource, $path, ContextSource\getConfig(), SpecialVersion\getCredits(), and ExtensionRegistry\getInstance().

◆ getParameter()

◆ getParameterFromSettings()

ApiBase::getParameterFromSettings (   $name,
  $settings,
  $parseLimit 
)
protected

Using the settings determine the value for the given parameter.

Parameters
string$nameParameter name
array | mixed$settingsDefault value or an array of settings using PARAM_* constants.
bool$parseLimitWhether to parse and validate 'limit' parameters
Returns
mixed Parameter value

Reimplemented in ApiFormatBase.

Definition at line 1051 of file ApiBase.php.

References encodeParamName(), getMain(), getModuleName(), and getResult().

Referenced by extractRequestParams().

◆ getParent()

ApiBase::getParent ( )

Get the parent of this module Stable to override.

Since
1.25
Returns
ApiBase|null

Reimplemented in ApiQueryBase.

Definition at line 478 of file ApiBase.php.

References getMain(), and isMain().

Referenced by getModulePath().

◆ getPermissionManager()

ApiBase::getPermissionManager ( )
protected

◆ getResult()

ApiBase::getResult ( )

Get the result object.

Returns
ApiResult

Reimplemented in ApiMain.

Definition at line 564 of file ApiBase.php.

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

Referenced by ApiQueryBase\addPageSubItem(), ApiQueryBase\addPageSubItems(), ApiQuerySiteinfo\appendDbReplLagInfo(), ApiQuerySiteinfo\appendDefaultOptions(), ApiQuerySiteinfo\appendExtensions(), ApiQuerySiteinfo\appendExtensionTags(), ApiQuerySiteinfo\appendFileExtensions(), ApiQuerySiteinfo\appendFunctionHooks(), ApiQuerySiteinfo\appendGeneralInfo(), ApiQuerySiteinfo\appendInstalledLibraries(), ApiQuerySiteinfo\appendInterwikiMap(), ApiQuerySiteinfo\appendLanguages(), ApiQuerySiteinfo\appendLanguageVariants(), ApiQuerySiteinfo\appendMagicWords(), ApiQuerySiteinfo\appendNamespaceAliases(), ApiQuerySiteinfo\appendNamespaces(), ApiQuerySiteinfo\appendProtocols(), ApiQuerySiteinfo\appendRestrictions(), ApiQuerySiteinfo\appendRightsInfo(), ApiQuerySiteinfo\appendSkins(), ApiQuerySiteinfo\appendSpecialPageAliases(), ApiQuerySiteinfo\appendStatistics(), ApiQuerySiteinfo\appendSubscribedHooks(), ApiQuerySiteinfo\appendUploadDialog(), ApiQuerySiteinfo\appendUserGroups(), ApiQuerySiteinfo\appendVariables(), ApiFormatRaw\closePrinter(), ApiValidatePassword\execute(), ApiChangeContentModel\execute(), ApiManageTags\execute(), ApiEmailUser\execute(), ApiImageRotate\execute(), ApiTokens\execute(), ApiImport\execute(), ApiMergeHistory\execute(), ApiCheckToken\execute(), ApiClearHasMsg\execute(), ApiRsd\execute(), ApiPurge\execute(), ApiQueryTags\execute(), ApiExpandTemplates\execute(), ApiRevisionDelete\execute(), ApiQueryMyStashedFiles\execute(), ApiHelp\execute(), ApiTag\execute(), ApiFormatPhp\execute(), ApiOpenSearchFormatJson\execute(), ApiQueryPageProps\execute(), ApiPatrol\execute(), ApiQueryAllMessages\execute(), ApiQueryStashImageInfo\execute(), ApiSetNotificationTimestamp\execute(), ApiChangeAuthenticationData\execute(), ApiProtect\execute(), ApiQueryTokens\execute(), ApiUndelete\execute(), ApiFileRevert\execute(), ApiQueryAuthManagerInfo\execute(), ApiOptions\execute(), ApiQueryBlocks\execute(), ApiParamInfo\execute(), ApiStashEdit\execute(), ApiQueryPagePropNames\execute(), ApiMove\execute(), ApiQueryFilearchive\execute(), ApiUpload\execute(), ApiFormatXml\execute(), ApiQueryDeletedrevs\execute(), ApiQueryImageInfo\execute(), ApiFeedRecentChanges\execute(), ApiCSPReport\execute(), ApiQueryFileRepoInfo\execute(), ApiQueryUserInfo\execute(), ApiQueryLogEvents\execute(), ApiQueryAllUsers\execute(), ApiWatch\execute(), ApiQueryContributors\execute(), ApiEditPage\execute(), ApiQueryUserContribs\execute(), ApiSetPageLanguage\execute(), ApiRemoveAuthenticationData\execute(), ApiDelete\execute(), ApiRollback\execute(), ApiFeedWatchlist\execute(), ApiFeedContributions\execute(), ApiUserrights\execute(), ApiAMCreateAccount\execute(), ApiLinkAccount\execute(), ApiClientLogin\execute(), ApiComparePages\execute(), ApiResetPassword\execute(), ApiFormatJson\execute(), ApiUnblock\execute(), ApiLogin\execute(), ApiBlock\execute(), ApiFormatRaw\execute(), ApiParse\execute(), ApiFormatFeedWrapper\execute(), ApiQueryLanguageinfo\execute(), ApiQueryUsers\execute(), ApiQuery\execute(), ApiQueryInfo\execute(), ApiFormatRaw\getFilename(), ApiFormatRaw\getMimeType(), getParameterFromSettings(), ApiFormatRaw\initPrinter(), ApiFormatFeedWrapper\initPrinter(), ApiQuery\outputGeneralPageInfo(), ApiQueryRevisionsBase\parseParameters(), ApiOpenSearch\populateResult(), ApiQueryAllRevisions\run(), ApiQueryAllDeletedRevisions\run(), ApiQueryProtectedTitles\run(), ApiQueryPrefixSearch\run(), ApiQueryIWBacklinks\run(), ApiQueryLangBacklinks\run(), ApiQueryExtLinksUsage\run(), ApiQueryAllCategories\run(), ApiQueryWatchlistRaw\run(), ApiQuerySearch\run(), ApiQueryPagesWithProp\run(), ApiQueryCategoryMembers\run(), ApiQueryAllPages\run(), ApiQueryWatchlist\run(), ApiQueryAllImages\run(), ApiQueryQueryPage\run(), ApiQueryAllLinks\run(), ApiQueryRandom\run(), ApiQueryRecentChanges\run(), ApiQueryRandom\runQuery(), and ApiUpload\selectUploadModule().

◆ getSummaryMessage()

ApiBase::getSummaryMessage ( )
protected

Return the summary message.

This is a one-line description of the module, suitable for display in a list of modules.

Since
1.30 Stable to override
Returns
string|array|Message

Reimplemented in ApiDisabled, and ApiQueryDisabled.

Definition at line 1630 of file ApiBase.php.

Referenced by getFinalDescription(), and getFinalSummary().

◆ getTitleFromTitleOrPageId()

ApiBase::getTitleFromTitleOrPageId (   $params)

Get a Title object from a title or pageid param, if possible.

Can die, if no param is set or if the title or page id is not valid.

Since
1.29
Parameters
array$paramsUser provided set of parameters, as from $this->extractRequestParams()
Returns
Title

Definition at line 1022 of file ApiBase.php.

References dieWithError(), Title\newFromID(), Title\newFromText(), requireOnlyOneParameter(), and wfEscapeWikiText().

◆ getTitleOrPageId()

ApiBase::getTitleOrPageId (   $params,
  $load = false 
)

Get a WikiPage object from a title or pageid param, if possible.

Can die, if no param is set or if the title or page id is not valid.

Parameters
array$paramsUser provided set of parameters, as from $this->extractRequestParams()
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 replica DB
  • 'fromdbmaster': load from the master database
Returns
WikiPage

Definition at line 985 of file ApiBase.php.

References dieWithError(), WikiPage\factory(), WikiPage\newFromID(), Title\newFromText(), requireOnlyOneParameter(), and wfEscapeWikiText().

Referenced by ApiChangeContentModel\execute(), ApiProtect\execute(), ApiStashEdit\execute(), ApiSetPageLanguage\execute(), ApiEditPage\execute(), ApiDelete\execute(), ApiParse\execute(), and ApiQueryCategoryMembers\run().

◆ getWatchlistUser()

ApiBase::getWatchlistUser (   $params)

Gets the user for whom to get the watchlist.

Parameters
array$params
Returns
User

Definition at line 1132 of file ApiBase.php.

References checkUserRightsAny(), dieWithError(), ContextSource\getUser(), User\newFromName(), and wfEscapeWikiText().

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

◆ getWebUITokenSalt()

ApiBase::getWebUITokenSalt ( array  $params)
protected

Fetch the salt used in the Web UI corresponding to this module.

Only override this if the Web UI uses a token with a non-constant salt.

Since
1.24
Parameters
array$paramsAll supplied parameters for the module Stable to override
Returns
string|array|null

Reimplemented in ApiUserrights, and ApiLogout.

Definition at line 411 of file ApiBase.php.

Referenced by validateToken().

◆ handleParamNormalization()

ApiBase::handleParamNormalization (   $paramName,
  $value,
  $rawValue 
)

Handle when a parameter was Unicode-normalized.

Since
1.28
1.35 $paramName is prefixed

Reimplemented in ApiPageSet.

Definition at line 1077 of file ApiBase.php.

References addWarning().

◆ isDeprecated()

ApiBase::isDeprecated ( )

Indicates whether this module is deprecated.

Since
1.25 Stable to override
Returns
bool

Reimplemented in ApiQueryDeletedrevs, ApiLogin, and ApiTokens.

Definition at line 363 of file ApiBase.php.

Referenced by getHelpFlags().

◆ isInternal()

ApiBase::isInternal ( )

Indicates whether this module is "internal" Internal API modules are not (yet) intended for 3rd party use and may be unstable.

Since
1.25 Stable to override
Returns
bool

Reimplemented in ApiCSPReport, and ApiStashEdit.

Definition at line 374 of file ApiBase.php.

Referenced by getHelpFlags().

◆ isMain()

ApiBase::isMain ( )

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

Returns
bool

Definition at line 468 of file ApiBase.php.

References $mMainModule.

Referenced by __construct(), getContinuationManager(), getErrorFormatter(), getFinalParamDescription(), getModulePath(), getParent(), getResult(), MediaWiki\Api\Validator\SubmoduleDef\getSubmoduleMap(), lacksSameOriginSecurity(), and setContinuationManager().

◆ isReadMode()

ApiBase::isReadMode ( )

Indicates whether this module requires read rights Stable to override.

Returns
bool

Reimplemented in ApiMain, ApiHelp, ApiQuery, ApiParamInfo, ApiCSPReport, ApiLogin, ApiQueryTokens, ApiClientLogin, ApiAMCreateAccount, ApiLinkAccount, ApiQueryAuthManagerInfo, ApiLogout, ApiRsd, and ApiDisabled.

Definition at line 328 of file ApiBase.php.

Referenced by getHelpFlags().

◆ isWriteMode()

ApiBase::isWriteMode ( )

Indicates whether this module requires write mode.

This should return true for modules that may require synchronous database writes. Modules that do not need such writes should also not rely on master database access, since only read queries are needed and each master DB is a single point of failure. Additionally, requests that only need replica DBs can be efficiently routed to any datacenter via the Promise-Non-Write-API-Action header.

Stable to override

Returns
bool

Reimplemented in ApiUpload, ApiEditPage, ApiMove, ApiStashEdit, ApiDelete, ApiOptions, ApiSetNotificationTimestamp, ApiBlock, ApiTag, ApiWatch, ApiUserrights, ApiImageRotate, ApiRevisionDelete, ApiProtect, ApiImport, ApiUnblock, ApiPurge, ApiRollback, ApiChangeContentModel, ApiUndelete, ApiAMCreateAccount, ApiSetPageLanguage, ApiFileRevert, ApiLinkAccount, ApiMergeHistory, ApiManageTags, ApiRemoveAuthenticationData, ApiResetPassword, ApiPatrol, ApiEmailUser, ApiChangeAuthenticationData, and ApiClearHasMsg.

Definition at line 344 of file ApiBase.php.

Referenced by getHelpFlags(), and ApiMain\setRequestExpectations().

◆ lacksSameOriginSecurity()

ApiBase::lacksSameOriginSecurity ( )

◆ logFeatureUsage()

ApiBase::logFeatureUsage (   $feature)

Write logging information for API features to a debug log, for usage analysis.

Note
Consider using $this->addDeprecation() instead to both warn and log.
Parameters
string$featureFeature being used.

Definition at line 1583 of file ApiBase.php.

References $s, getMain(), ContextSource\getRequest(), ContextSource\getUser(), wfDebugLog(), and wfUrlencode().

Referenced by addDeprecation().

◆ makeMessage()

static ApiBase::makeMessage (   $msg,
IContextSource  $context,
array  $params = null 
)
static

Create a Message from a string or array.

A string is used as a message key. An array has the message key as the first value and message parameters as subsequent values.

Since
1.25
Parameters
string | array | Message$msg
IContextSource$context
array | null$params
Returns
Message|null

Definition at line 1167 of file ApiBase.php.

References ContextSource\$context, and wfMessage().

Referenced by MediaWiki\Api\Validator\ApiParamValidator\checkSettingsMessage(), ApiAMCreateAccount\getFinalDescription(), ApiLinkAccount\getFinalDescription(), ApiClientLogin\getFinalDescription(), getFinalDescription(), getFinalParamDescription(), getFinalSummary(), ApiHelp\getHelpInternal(), and ApiParamInfo\getModuleInfo().

◆ modifyHelp()

ApiBase::modifyHelp ( array &  $help,
array  $options,
array &  $tocData 
)

Called from ApiHelp before the pieces are joined together and returned.

This exists mainly for ApiMain to add the Permissions and Credits sections. Other modules probably don't need it.

Stable to override

Parameters
string[]&$helpArray of help data
array$optionsOptions passed to ApiHelp::getHelp
array&$tocDataIf a TOC is being generated, this array has keys as anchors in the page and values as for Linker::generateTOC().

Reimplemented in ApiMain.

Definition at line 1996 of file ApiBase.php.

◆ mustBePosted()

◆ needsToken()

ApiBase::needsToken ( )

Returns the token type this module requires in order to execute.

Modules are strongly encouraged to use the core 'csrf' type unless they have specialized security needs. If the token type is not one of the core types, you must use the ApiQueryTokensRegisterTypes hook to register it.

Returning a non-falsey value here will force the addition of an appropriate 'token' parameter in self::getFinalParams(). Also, self::mustBePosted() must return true when tokens are used.

In previous versions of MediaWiki, true was a valid return value. Returning true will generate errors indicating that the API module needs updating.

Stable to override

Returns
string|false

Reimplemented in ApiUpload, ApiEditPage, ApiMove, ApiDelete, ApiBlock, ApiOptions, ApiStashEdit, ApiUserrights, ApiTag, ApiSetNotificationTimestamp, ApiImageRotate, ApiRevisionDelete, ApiProtect, ApiWatch, ApiImport, ApiRollback, ApiUnblock, ApiUndelete, ApiSetPageLanguage, ApiFileRevert, ApiMergeHistory, ApiChangeContentModel, ApiManageTags, ApiClientLogin, ApiAMCreateAccount, ApiLinkAccount, ApiPatrol, ApiEmailUser, ApiRemoveAuthenticationData, ApiResetPassword, ApiChangeAuthenticationData, and ApiLogout.

Definition at line 397 of file ApiBase.php.

Referenced by getFinalParams(), mustBePosted(), and validateToken().

◆ parameterNotEmpty()

ApiBase::parameterNotEmpty (   $x)
private

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

Parameters
object$xParameter to check is not null/false
Returns
bool

Definition at line 970 of file ApiBase.php.

◆ parseMultiValue()

ApiBase::parseMultiValue (   $valueName,
  $value,
  $allowMultiple,
  $allowedValues,
  $allSpecifier = null,
  $limit1 = null,
  $limit2 = null 
)
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.

Deprecated:
since 1.35, no replacement
Parameters
string$valueNameThe name of the parameter (for error reporting)
mixed$valueThe value being parsed
bool$allowMultipleCan $value contain more than one value separated by '|'?
string[] | null$allowedValuesAn array of values to check against. If null, all values are accepted.
string | null$allSpecifierString to use to specify all allowed values, or null if this behavior should not be allowed
int | null$limit1Maximum number of values, for normal users.
int | null$limit2Maximum number of values, for users with the apihighlimits right.
Returns
string|string[] (allowMultiple ? an_array_of_values : a_single_value)

Definition at line 2037 of file ApiBase.php.

References addWarning(), dieWithError(), explodeMultiValue(), LIMIT_SML1, LIMIT_SML2, Message\listParam(), wfDeprecated(), and wfEscapeWikiText().

◆ requireAtLeastOneParameter()

ApiBase::requireAtLeastOneParameter (   $params,
  $required 
)

Die if none of a certain set of parameters is set and not false.

Since
1.23
Parameters
array$paramsUser provided set of parameters, as from $this->extractRequestParams()
string...$required Names of parameters of which at least one must be set

Definition at line 913 of file ApiBase.php.

References dieWithError(), encodeParamName(), and Message\listParam().

Referenced by ApiTag\execute(), ApiQueryStashImageInfo\execute(), ApiEditPage\execute(), ApiLinkAccount\execute(), ApiAMCreateAccount\execute(), ApiClientLogin\execute(), and ApiComparePages\execute().

◆ requireMaxOneParameter()

ApiBase::requireMaxOneParameter (   $params,
  $required 
)

◆ requireOnlyOneParameter()

ApiBase::requireOnlyOneParameter (   $params,
  $required 
)

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

Parameters
array$paramsUser provided set of parameters, as from $this->extractRequestParams()
string...$required Names of parameters of which exactly one must be set

Definition at line 853 of file ApiBase.php.

References dieWithError(), encodeParamName(), and Message\listParam().

Referenced by ApiMergeHistory\execute(), ApiPatrol\execute(), ApiStashEdit\execute(), ApiMove\execute(), ApiQueryUserContribs\execute(), ApiResetPassword\execute(), ApiUnblock\execute(), ApiBlock\execute(), ApiRollback\getRbTitle(), getTitleFromTitleOrPageId(), getTitleOrPageId(), ApiUserrights\getUrUser(), and ApiUpload\selectUploadModule().

◆ requirePostedParameters()

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

Since
1.28
Parameters
string[]$paramsParameters to check
string$prefixSet to 'noprefix' to skip calling $this->encodeParamName()

Definition at line 940 of file ApiBase.php.

References dieWithError(), encodeParamName(), ContextSource\getConfig(), getMain(), and ContextSource\getRequest().

Referenced by ApiValidatePassword\execute(), and ApiLogin\execute().

◆ setContinuationManager()

ApiBase::setContinuationManager ( ApiContinuationManager  $manager = null)

Set the continuation manager.

Parameters
ApiContinuationManager | null$manager

Reimplemented in ApiMain.

Definition at line 620 of file ApiBase.php.

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

Referenced by ApiImageRotate\execute(), ApiPurge\execute(), ApiSetNotificationTimestamp\execute(), ApiWatch\execute(), and ApiQuery\execute().

◆ shouldCheckMaxlag()

ApiBase::shouldCheckMaxlag ( )

Indicates if this module needs maxlag to be checked Stable to override.

Returns
bool

Reimplemented in ApiHelp.

Definition at line 319 of file ApiBase.php.

◆ useTransactionalTimeLimit()

◆ validateLimit()

ApiBase::validateLimit (   $name,
$value,
  $min,
  $max,
  $botMax = null,
  $enforceLimits = false 
)
protected

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

Prints usage info on failure.

Deprecated:
since 1.35, use $this->getMain()->getParamValidator()->validateValue() instead.
Parameters
string$nameParameter name, unprefixed
int&$valueParameter value
int | null$minMinimum value
int | null$maxMaximum value for users
int | null$botMaxMaximum value for sysops/bots
bool$enforceLimitsWhether to enforce (die) if value is outside limits

Definition at line 2121 of file ApiBase.php.

References getMain(), and wfDeprecated().

◆ validateTimestamp()

ApiBase::validateTimestamp (   $value,
  $encParamName 
)
protected

Validate and normalize parameters of type 'timestamp'.

Deprecated:
since 1.35, use $this->getMain()->getParamValidator()->validateValue() instead.
Parameters
string$valueParameter value
string$encParamNameParameter name
Returns
string Validated and normalized parameter

Definition at line 2143 of file ApiBase.php.

References getMain(), getModulePrefix(), and wfDeprecated().

◆ validateToken()

ApiBase::validateToken (   $token,
array  $params 
)
final

Validate the supplied token.

Since
1.24
Parameters
string$tokenSupplied token
array$paramsAll supplied parameters for the module
Returns
bool
Exceptions
MWException

Definition at line 1090 of file ApiBase.php.

References ContextSource\getRequest(), ApiQueryTokens\getToken(), ApiQueryTokens\getTokenTypeSalts(), ContextSource\getUser(), getWebUITokenSalt(), and needsToken().

Member Data Documentation

◆ $blockMsgMap

ApiBase::$blockMsgMap
staticprivate
Initial value:
= [
'blockedtext' => [ 'apierror-blocked', 'blocked' ],
'blockedtext-partial' => [ 'apierror-blocked-partial', 'blocked' ],
'autoblockedtext' => [ 'apierror-autoblocked', 'autoblocked' ],
'systemblockedtext' => [ 'apierror-systemblocked', 'blocked' ],
'blockedtext-composite' => [ 'apierror-blocked', 'blocked' ],
]

$var array Map of web UI block messages to corresponding API messages and codes

Definition at line 186 of file ApiBase.php.

◆ $extensionInfo

array ApiBase::$extensionInfo = null
staticprivate

Maps extension paths to info arrays.

Definition at line 180 of file ApiBase.php.

◆ $filterIDsCache

stdClass [][] ApiBase::$filterIDsCache = []
staticprivate

Cache for self::filterIDs()

Definition at line 183 of file ApiBase.php.

◆ $hookContainer

HookContainer ApiBase::$hookContainer
private

Definition at line 57 of file ApiBase.php.

Referenced by getHookContainer(), and ApiQueryTokens\getTokenTypeSalts().

◆ $hookRunner

ApiHookRunner ApiBase::$hookRunner
private

Definition at line 60 of file ApiBase.php.

Referenced by getHookRunner(), and ApiQueryTokens\getTokenTypeSalts().

◆ $mMainModule

ApiMain ApiBase::$mMainModule
private

Definition at line 195 of file ApiBase.php.

Referenced by getMain(), and isMain().

◆ $mModuleName

string ApiBase::$mModuleName
private

Definition at line 197 of file ApiBase.php.

Referenced by getModuleName().

◆ $mModulePrefix

string ApiBase::$mModulePrefix

Definition at line 197 of file ApiBase.php.

Referenced by getModulePrefix().

◆ $mModuleSource

array null bool ApiBase::$mModuleSource = false
private

Definition at line 204 of file ApiBase.php.

Referenced by getModuleSourceInfo().

◆ $mParamCache

array ApiBase::$mParamCache = []
private

Definition at line 202 of file ApiBase.php.

◆ $mReplicaDB

ApiBase::$mReplicaDB = null
private

Definition at line 198 of file ApiBase.php.

Referenced by getDB().

◆ ALL_DEFAULT_STRING

const ApiBase::ALL_DEFAULT_STRING = '*'

Definition at line 161 of file ApiBase.php.

◆ GET_VALUES_FOR_HELP

const ApiBase::GET_VALUES_FOR_HELP = 1

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 177 of file ApiBase.php.

Referenced by ApiUserrights\getAllowedParams(), ApiQueryContributors\getAllowedParams(), ApiQueryAllUsers\getAllowedParams(), ApiQueryLogEvents\getAllowedParams(), ApiPageSet\getAllowedParams(), ApiHelp\getHelpInternal(), and ApiParamInfo\getModuleInfo().

◆ LIMIT_BIG1

const ApiBase::LIMIT_BIG1 = 500

Fast query, standard limit.

Definition at line 164 of file ApiBase.php.

Referenced by buildCommonApiParams(), ApiQueryDeletedrevs\execute(), ApiQueryPagePropNames\getAllowedParams(), ApiQueryMyStashedFiles\getAllowedParams(), ApiQueryTags\getAllowedParams(), ApiQueryPagesWithProp\getAllowedParams(), ApiQueryImages\getAllowedParams(), ApiQueryLangLinks\getAllowedParams(), ApiQueryExternalLinks\getAllowedParams(), ApiQueryIWLinks\getAllowedParams(), ApiQueryAllCategories\getAllowedParams(), ApiQueryWatchlistRaw\getAllowedParams(), ApiQueryDuplicateFiles\getAllowedParams(), ApiQueryQueryPage\getAllowedParams(), ApiQueryLangBacklinks\getAllowedParams(), ApiQueryIWBacklinks\getAllowedParams(), ApiQueryCategories\getAllowedParams(), ApiQueryRandom\getAllowedParams(), ApiQueryProtectedTitles\getAllowedParams(), ApiQueryLinks\getAllowedParams(), ApiQueryExtLinksUsage\getAllowedParams(), ApiQueryContributors\getAllowedParams(), ApiQueryFilearchive\getAllowedParams(), ApiQueryAllLinks\getAllowedParams(), ApiQueryAllPages\getAllowedParams(), ApiQueryCategoryMembers\getAllowedParams(), ApiQueryAllUsers\getAllowedParams(), ApiQueryAllImages\getAllowedParams(), ApiQueryBlocks\getAllowedParams(), ApiQueryBacklinksprop\getAllowedParams(), ApiQueryLogEvents\getAllowedParams(), ApiQueryWatchlist\getAllowedParams(), ApiQueryDeletedrevs\getAllowedParams(), ApiQueryBacklinks\getAllowedParams(), ApiQueryUserContribs\getAllowedParams(), ApiQueryImageInfo\getAllowedParams(), ApiQueryRevisionsBase\getAllowedParams(), ApiQueryRecentChanges\getAllowedParams(), ApiQueryRevisionsBase\parseParameters(), and ApiQueryBacklinks\run().

◆ LIMIT_BIG2

const ApiBase::LIMIT_BIG2 = 5000

Fast query, apihighlimits limit.

Definition at line 166 of file ApiBase.php.

Referenced by buildCommonApiParams(), ApiQueryDeletedrevs\execute(), ApiQueryPagePropNames\getAllowedParams(), ApiQueryMyStashedFiles\getAllowedParams(), ApiQueryTags\getAllowedParams(), ApiQueryPagesWithProp\getAllowedParams(), ApiQueryImages\getAllowedParams(), ApiQueryLangLinks\getAllowedParams(), ApiQueryExternalLinks\getAllowedParams(), ApiQueryIWLinks\getAllowedParams(), ApiQueryAllCategories\getAllowedParams(), ApiQueryWatchlistRaw\getAllowedParams(), ApiQueryDuplicateFiles\getAllowedParams(), ApiQueryQueryPage\getAllowedParams(), ApiQueryLangBacklinks\getAllowedParams(), ApiQueryIWBacklinks\getAllowedParams(), ApiQueryCategories\getAllowedParams(), ApiQueryRandom\getAllowedParams(), ApiQueryProtectedTitles\getAllowedParams(), ApiQueryLinks\getAllowedParams(), ApiQueryExtLinksUsage\getAllowedParams(), ApiQueryContributors\getAllowedParams(), ApiQueryFilearchive\getAllowedParams(), ApiQueryAllLinks\getAllowedParams(), ApiQueryAllPages\getAllowedParams(), ApiQueryCategoryMembers\getAllowedParams(), ApiQueryAllUsers\getAllowedParams(), ApiQueryAllImages\getAllowedParams(), ApiQueryBlocks\getAllowedParams(), ApiQueryBacklinksprop\getAllowedParams(), ApiQueryLogEvents\getAllowedParams(), ApiQueryWatchlist\getAllowedParams(), ApiQueryDeletedrevs\getAllowedParams(), ApiQueryBacklinks\getAllowedParams(), ApiQueryUserContribs\getAllowedParams(), ApiQueryImageInfo\getAllowedParams(), ApiQueryRevisionsBase\getAllowedParams(), ApiQueryRecentChanges\getAllowedParams(), ApiQueryRevisionsBase\parseParameters(), and ApiQueryBacklinks\run().

◆ LIMIT_SML1

◆ LIMIT_SML2

const ApiBase::LIMIT_SML2 = 500

◆ PARAM_ALL

const ApiBase::PARAM_ALL = ParamValidator::PARAM_ALL

(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE

Deprecated:
since 1.35

Definition at line 79 of file ApiBase.php.

Referenced by ApiComparePages\getAllowedParams(), and ApiQueryRevisionsBase\getAllowedParams().

◆ PARAM_ALLOW_DUPLICATES

const ApiBase::PARAM_ALLOW_DUPLICATES = ParamValidator::PARAM_ALLOW_DUPLICATES

(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE

Deprecated:
since 1.35

Definition at line 74 of file ApiBase.php.

Referenced by ApiProtect\getAllowedParams(), ApiUserrights\getAllowedParams(), and ApiQueryAllMessages\getAllowedParams().

◆ PARAM_DEPRECATED

◆ PARAM_DEPRECATED_VALUES

const ApiBase::PARAM_DEPRECATED_VALUES = EnumDef::PARAM_DEPRECATED_VALUES

◆ PARAM_DFLT

const ApiBase::PARAM_DFLT = ParamValidator::PARAM_DEFAULT

(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE

Deprecated:
since 1.35

Definition at line 68 of file ApiBase.php.

Referenced by buildCommonApiParams(), buildProfileApiParam(), ApiFormatPhp\getAllowedParams(), ApiQueryFileRepoInfo\getAllowedParams(), ApiQueryPagePropNames\getAllowedParams(), ApiTokens\getAllowedParams(), ApiManageTags\getAllowedParams(), ApiQueryStashImageInfo\getAllowedParams(), ApiFileRevert\getAllowedParams(), ApiQueryTokens\getAllowedParams(), ApiQueryMyStashedFiles\getAllowedParams(), ApiFormatJson\getAllowedParams(), ApiFeedRecentChanges\getAllowedParams(), ApiQueryTags\getAllowedParams(), ApiQueryPagesWithProp\getAllowedParams(), ApiQueryImages\getAllowedParams(), ApiQueryLangLinks\getAllowedParams(), ApiQueryExternalLinks\getAllowedParams(), ApiProtect\getAllowedParams(), ApiQueryIWLinks\getAllowedParams(), ApiQueryAllCategories\getAllowedParams(), ApiRevisionDelete\getAllowedParams(), ApiQueryWatchlistRaw\getAllowedParams(), ApiQueryDuplicateFiles\getAllowedParams(), ApiUserrights\getAllowedParams(), ApiQueryQueryPage\getAllowedParams(), ApiQueryLangBacklinks\getAllowedParams(), ApiQueryIWBacklinks\getAllowedParams(), ApiTag\getAllowedParams(), ApiQueryCategories\getAllowedParams(), ApiStashEdit\getAllowedParams(), ApiQueryProtectedTitles\getAllowedParams(), ApiQueryRandom\getAllowedParams(), ApiQueryLinks\getAllowedParams(), ApiQueryExtLinksUsage\getAllowedParams(), ApiQueryAllMessages\getAllowedParams(), ApiFeedContributions\getAllowedParams(), ApiOptions\getAllowedParams(), ApiDelete\getAllowedParams(), ApiQueryContributors\getAllowedParams(), ApiFeedWatchlist\getAllowedParams(), ApiQueryFilearchive\getAllowedParams(), ApiCSPReport\getAllowedParams(), ApiQueryAllLinks\getAllowedParams(), ApiQueryAllPages\getAllowedParams(), ApiQueryDeletedRevisions\getAllowedParams(), ApiQueryAllRevisions\getAllowedParams(), ApiOpenSearch\getAllowedParams(), ApiFormatXml\getAllowedParams(), ApiQueryCategoryMembers\getAllowedParams(), ApiQueryAllUsers\getAllowedParams(), ApiQueryAllImages\getAllowedParams(), ApiQueryBlocks\getAllowedParams(), ApiQuerySearch\getAllowedParams(), ApiFormatBase\getAllowedParams(), ApiQueryBacklinksprop\getAllowedParams(), ApiParamInfo\getAllowedParams(), ApiQueryLogEvents\getAllowedParams(), ApiQueryAllDeletedRevisions\getAllowedParams(), ApiQueryWatchlist\getAllowedParams(), ApiQueryDeletedrevs\getAllowedParams(), ApiQueryRevisions\getAllowedParams(), ApiQuery\getAllowedParams(), ApiQueryBacklinks\getAllowedParams(), ApiQueryUserContribs\getAllowedParams(), ApiEditPage\getAllowedParams(), ApiComparePages\getAllowedParams(), ApiHelp\getAllowedParams(), ApiQueryImageInfo\getAllowedParams(), ApiQueryRevisionsBase\getAllowedParams(), ApiQueryRecentChanges\getAllowedParams(), ApiParse\getAllowedParams(), ApiQuerySiteinfo\getAllowedParams(), ApiUpload\getAllowedParams(), ApiQueryInfo\getAllowedParams(), ApiPageSet\getAllowedParams(), ApiMain\getAllowedParams(), ApiOpenSearch\getFormat(), ApiFormatBase\getParameterFromSettings(), and ApiAuthManagerHelper\getStandardParams().

◆ PARAM_EXTRA_NAMESPACES

const ApiBase::PARAM_EXTRA_NAMESPACES = NamespaceDef::PARAM_EXTRA_NAMESPACES

(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE

Deprecated:
since 1.35

Definition at line 80 of file ApiBase.php.

Referenced by ApiQueryLinks\getAllowedParams(), ApiQueryAllLinks\getAllowedParams(), ApiQueryLogEvents\getAllowedParams(), and ApiQueryRecentChanges\getAllowedParams().

◆ PARAM_HELP_MSG

const ApiBase::PARAM_HELP_MSG = 'api-param-help-msg'

(string|array|Message) Specify an alternative i18n documentation message for this parameter.

Default is apihelp-{$path}-param-{$param}.

Since
1.25

Definition at line 106 of file ApiBase.php.

Referenced by buildCommonApiParams(), buildProfileApiParam(), MediaWiki\Api\Validator\ApiParamValidator\checkSettings(), ApiFormatPhp\getAllowedParams(), ApiQueryPagePropNames\getAllowedParams(), ApiQueryCategoryInfo\getAllowedParams(), ApiQueryPageProps\getAllowedParams(), ApiQueryStashImageInfo\getAllowedParams(), ApiQueryMyStashedFiles\getAllowedParams(), ApiFormatJson\getAllowedParams(), ApiQueryTags\getAllowedParams(), ApiPurge\getAllowedParams(), ApiQueryPagesWithProp\getAllowedParams(), ApiQueryImages\getAllowedParams(), ApiQueryLangLinks\getAllowedParams(), ApiQueryExternalLinks\getAllowedParams(), ApiQueryIWLinks\getAllowedParams(), ApiQueryAllCategories\getAllowedParams(), ApiQueryWatchlistRaw\getAllowedParams(), ApiQueryDuplicateFiles\getAllowedParams(), ApiImageRotate\getAllowedParams(), ApiQueryQueryPage\getAllowedParams(), ApiQueryLangBacklinks\getAllowedParams(), ApiWatch\getAllowedParams(), ApiQueryIWBacklinks\getAllowedParams(), ApiQueryCategories\getAllowedParams(), ApiQueryProtectedTitles\getAllowedParams(), ApiQueryRandom\getAllowedParams(), ApiQueryLinks\getAllowedParams(), ApiQueryExtLinksUsage\getAllowedParams(), ApiSetNotificationTimestamp\getAllowedParams(), ApiFeedContributions\getAllowedParams(), ApiQueryContributors\getAllowedParams(), ApiFeedWatchlist\getAllowedParams(), ApiQueryFilearchive\getAllowedParams(), ApiLogin\getAllowedParams(), ApiQueryAllLinks\getAllowedParams(), ApiQueryAllPages\getAllowedParams(), ApiQueryDeletedRevisions\getAllowedParams(), ApiQueryAllRevisions\getAllowedParams(), ApiFormatXml\getAllowedParams(), ApiQueryCategoryMembers\getAllowedParams(), ApiQueryAllUsers\getAllowedParams(), ApiQueryAllImages\getAllowedParams(), ApiQueryBlocks\getAllowedParams(), ApiFormatBase\getAllowedParams(), ApiQueryBacklinksprop\getAllowedParams(), ApiQueryLogEvents\getAllowedParams(), ApiQueryAllDeletedRevisions\getAllowedParams(), ApiQueryWatchlist\getAllowedParams(), ApiQueryDeletedrevs\getAllowedParams(), ApiQueryRevisions\getAllowedParams(), ApiQuery\getAllowedParams(), ApiQueryBacklinks\getAllowedParams(), ApiQueryUserContribs\getAllowedParams(), ApiQueryImageInfo\getAllowedParams(), ApiQueryRevisionsBase\getAllowedParams(), ApiQueryRecentChanges\getAllowedParams(), ApiParse\getAllowedParams(), ApiQueryInfo\getAllowedParams(), ApiPageSet\getAllowedParams(), getFinalParamDescription(), and ApiAuthManagerHelper\getStandardParams().

◆ PARAM_HELP_MSG_APPEND

◆ PARAM_HELP_MSG_INFO

const ApiBase::PARAM_HELP_MSG_INFO = 'api-param-help-msg-info'

(array) Specify additional information tags for the parameter.

Value is an array of arrays, with the first member being the 'tag' for the info and the remaining members being the values. In the help, this is formatted using apihelp-{$path}-paraminfo-{$tag}, which is passed $1 = count, $2 = comma-joined list of values, $3 = module prefix.

Since
1.25

Definition at line 123 of file ApiBase.php.

Referenced by MediaWiki\Api\Validator\ApiParamValidator\checkSettings(), ApiQueryAllDeletedRevisions\getAllowedParams(), ApiQueryDeletedrevs\getAllowedParams(), ApiQueryRevisions\getAllowedParams(), ApiHelp\getHelpInternal(), and ApiParamInfo\getModuleInfo().

◆ PARAM_HELP_MSG_PER_VALUE

const ApiBase::PARAM_HELP_MSG_PER_VALUE = 'api-param-help-msg-per-value'

((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg for ApiBase::makeMessage().

Any value not having a mapping will use apihelp-{$path}-paramvalue-{$param}-{$value}. Specify an empty array to use the default message key for all values.

Since
1.25

Definition at line 139 of file ApiBase.php.

Referenced by buildProfileApiParam(), MediaWiki\Api\Validator\ApiParamValidator\checkSettings(), ApiQueryFileRepoInfo\getAllowedParams(), ApiQueryStashImageInfo\getAllowedParams(), ApiQueryMyStashedFiles\getAllowedParams(), ApiQueryTags\getAllowedParams(), ApiQueryPagesWithProp\getAllowedParams(), ApiQueryLangLinks\getAllowedParams(), ApiQueryAllCategories\getAllowedParams(), ApiQueryIWLinks\getAllowedParams(), ApiQueryWatchlistRaw\getAllowedParams(), ApiQueryLangBacklinks\getAllowedParams(), ApiQueryIWBacklinks\getAllowedParams(), ApiQueryCategories\getAllowedParams(), ApiQueryProtectedTitles\getAllowedParams(), ApiExpandTemplates\getAllowedParams(), ApiQueryExtLinksUsage\getAllowedParams(), ApiFeedWatchlist\getAllowedParams(), ApiQueryFilearchive\getAllowedParams(), ApiQueryAllLinks\getAllowedParams(), ApiQueryCategoryMembers\getAllowedParams(), ApiQueryUserInfo\getAllowedParams(), ApiQueryAllUsers\getAllowedParams(), ApiQueryAllImages\getAllowedParams(), ApiQueryBlocks\getAllowedParams(), ApiQuerySearch\getAllowedParams(), ApiQueryBacklinksprop\getAllowedParams(), ApiQueryUsers\getAllowedParams(), ApiQueryLogEvents\getAllowedParams(), ApiQueryWatchlist\getAllowedParams(), ApiQueryUserContribs\getAllowedParams(), ApiComparePages\getAllowedParams(), ApiQueryImageInfo\getAllowedParams(), ApiQueryRevisionsBase\getAllowedParams(), ApiQueryRecentChanges\getAllowedParams(), ApiParse\getAllowedParams(), ApiQuerySiteinfo\getAllowedParams(), ApiQueryInfo\getAllowedParams(), and getFinalParamDescription().

◆ PARAM_ISMULTI

const ApiBase::PARAM_ISMULTI = ParamValidator::PARAM_ISMULTI

(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE

Deprecated:
since 1.35

Definition at line 69 of file ApiBase.php.

Referenced by buildCommonApiParams(), ApiQueryFileRepoInfo\getAllowedParams(), ApiChangeContentModel\getAllowedParams(), ApiPatrol\getAllowedParams(), ApiTokens\getAllowedParams(), ApiManageTags\getAllowedParams(), ApiQueryPageProps\getAllowedParams(), ApiQueryStashImageInfo\getAllowedParams(), ApiQueryTokens\getAllowedParams(), ApiSetPageLanguage\getAllowedParams(), ApiUndelete\getAllowedParams(), ApiQueryMyStashedFiles\getAllowedParams(), ApiRollback\getAllowedParams(), ApiQueryTags\getAllowedParams(), ApiUnblock\getAllowedParams(), ApiQueryPagesWithProp\getAllowedParams(), ApiImport\getAllowedParams(), ApiQueryImages\getAllowedParams(), ApiQueryLangLinks\getAllowedParams(), ApiProtect\getAllowedParams(), ApiQueryAllCategories\getAllowedParams(), ApiQueryIWLinks\getAllowedParams(), ApiRevisionDelete\getAllowedParams(), ApiQueryWatchlistRaw\getAllowedParams(), ApiImageRotate\getAllowedParams(), ApiUserrights\getAllowedParams(), ApiQueryLangBacklinks\getAllowedParams(), ApiQueryIWBacklinks\getAllowedParams(), ApiTag\getAllowedParams(), ApiQueryCategories\getAllowedParams(), ApiQueryProtectedTitles\getAllowedParams(), ApiQueryRandom\getAllowedParams(), ApiExpandTemplates\getAllowedParams(), ApiQueryLinks\getAllowedParams(), ApiBlock\getAllowedParams(), ApiQueryExtLinksUsage\getAllowedParams(), ApiQueryAllMessages\getAllowedParams(), ApiFeedContributions\getAllowedParams(), ApiOptions\getAllowedParams(), ApiDelete\getAllowedParams(), ApiQueryContributors\getAllowedParams(), ApiQueryFilearchive\getAllowedParams(), ApiMove\getAllowedParams(), ApiQueryAllLinks\getAllowedParams(), ApiQueryAllPages\getAllowedParams(), ApiQueryAllRevisions\getAllowedParams(), ApiQueryCategoryMembers\getAllowedParams(), ApiQueryUserInfo\getAllowedParams(), ApiQueryAllUsers\getAllowedParams(), ApiQueryAllImages\getAllowedParams(), ApiQueryBlocks\getAllowedParams(), ApiQuerySearch\getAllowedParams(), ApiQueryBacklinksprop\getAllowedParams(), ApiQueryUsers\getAllowedParams(), ApiParamInfo\getAllowedParams(), ApiQueryLogEvents\getAllowedParams(), ApiQueryAllDeletedRevisions\getAllowedParams(), ApiQueryWatchlist\getAllowedParams(), ApiQueryDeletedrevs\getAllowedParams(), ApiQueryRevisions\getAllowedParams(), ApiQuery\getAllowedParams(), ApiQueryBacklinks\getAllowedParams(), ApiQueryUserContribs\getAllowedParams(), ApiEditPage\getAllowedParams(), ApiComparePages\getAllowedParams(), ApiHelp\getAllowedParams(), ApiQueryImageInfo\getAllowedParams(), ApiQueryRevisionsBase\getAllowedParams(), ApiQueryRecentChanges\getAllowedParams(), ApiParse\getAllowedParams(), ApiQuerySiteinfo\getAllowedParams(), ApiUpload\getAllowedParams(), ApiQueryInfo\getAllowedParams(), ApiPageSet\getAllowedParams(), and ApiAuthManagerHelper\getStandardParams().

◆ PARAM_ISMULTI_LIMIT1

const ApiBase::PARAM_ISMULTI_LIMIT1 = ParamValidator::PARAM_ISMULTI_LIMIT1

(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE

Deprecated:
since 1.35

Definition at line 83 of file ApiBase.php.

Referenced by ApiBlock\getAllowedParams().

◆ PARAM_ISMULTI_LIMIT2

const ApiBase::PARAM_ISMULTI_LIMIT2 = ParamValidator::PARAM_ISMULTI_LIMIT2

(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE

Deprecated:
since 1.35

Definition at line 84 of file ApiBase.php.

Referenced by ApiBlock\getAllowedParams().

◆ PARAM_MAX

const ApiBase::PARAM_MAX = IntegerDef::PARAM_MAX

(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE

Deprecated:
since 1.35

Definition at line 71 of file ApiBase.php.

Referenced by buildCommonApiParams(), ApiQueryPagePropNames\getAllowedParams(), ApiQueryMyStashedFiles\getAllowedParams(), ApiFeedRecentChanges\getAllowedParams(), ApiQueryTags\getAllowedParams(), ApiQueryPagesWithProp\getAllowedParams(), ApiQueryImages\getAllowedParams(), ApiQueryLangLinks\getAllowedParams(), ApiQueryExternalLinks\getAllowedParams(), ApiQueryIWLinks\getAllowedParams(), ApiQueryAllCategories\getAllowedParams(), ApiQueryWatchlistRaw\getAllowedParams(), ApiQueryDuplicateFiles\getAllowedParams(), ApiQueryQueryPage\getAllowedParams(), ApiQueryLangBacklinks\getAllowedParams(), ApiQueryIWBacklinks\getAllowedParams(), ApiQueryCategories\getAllowedParams(), ApiQueryRandom\getAllowedParams(), ApiQueryProtectedTitles\getAllowedParams(), ApiQueryLinks\getAllowedParams(), ApiQueryExtLinksUsage\getAllowedParams(), ApiQueryContributors\getAllowedParams(), ApiFeedWatchlist\getAllowedParams(), ApiQueryFilearchive\getAllowedParams(), ApiQueryAllLinks\getAllowedParams(), ApiQueryAllPages\getAllowedParams(), ApiQueryCategoryMembers\getAllowedParams(), ApiQueryAllUsers\getAllowedParams(), ApiQueryAllImages\getAllowedParams(), ApiQueryBlocks\getAllowedParams(), ApiQueryBacklinksprop\getAllowedParams(), ApiQueryLogEvents\getAllowedParams(), ApiQueryWatchlist\getAllowedParams(), ApiQueryDeletedrevs\getAllowedParams(), ApiQueryBacklinks\getAllowedParams(), ApiQueryUserContribs\getAllowedParams(), ApiQueryImageInfo\getAllowedParams(), ApiQueryRevisionsBase\getAllowedParams(), ApiQueryRecentChanges\getAllowedParams(), and ApiUpload\getAllowedParams().

◆ PARAM_MAX2

const ApiBase::PARAM_MAX2 = IntegerDef::PARAM_MAX2

(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE

Deprecated:
since 1.35

Definition at line 72 of file ApiBase.php.

Referenced by buildCommonApiParams(), ApiQueryPagePropNames\getAllowedParams(), ApiQueryMyStashedFiles\getAllowedParams(), ApiQueryTags\getAllowedParams(), ApiQueryPagesWithProp\getAllowedParams(), ApiQueryImages\getAllowedParams(), ApiQueryLangLinks\getAllowedParams(), ApiQueryExternalLinks\getAllowedParams(), ApiQueryIWLinks\getAllowedParams(), ApiQueryAllCategories\getAllowedParams(), ApiQueryWatchlistRaw\getAllowedParams(), ApiQueryDuplicateFiles\getAllowedParams(), ApiQueryQueryPage\getAllowedParams(), ApiQueryLangBacklinks\getAllowedParams(), ApiQueryIWBacklinks\getAllowedParams(), ApiQueryCategories\getAllowedParams(), ApiQueryProtectedTitles\getAllowedParams(), ApiQueryRandom\getAllowedParams(), ApiQueryLinks\getAllowedParams(), ApiQueryExtLinksUsage\getAllowedParams(), ApiQueryContributors\getAllowedParams(), ApiQueryFilearchive\getAllowedParams(), ApiQueryAllLinks\getAllowedParams(), ApiQueryAllPages\getAllowedParams(), ApiQueryCategoryMembers\getAllowedParams(), ApiQueryAllUsers\getAllowedParams(), ApiQueryAllImages\getAllowedParams(), ApiQueryBlocks\getAllowedParams(), ApiQueryBacklinksprop\getAllowedParams(), ApiQueryLogEvents\getAllowedParams(), ApiQueryWatchlist\getAllowedParams(), ApiQueryDeletedrevs\getAllowedParams(), ApiQueryBacklinks\getAllowedParams(), ApiQueryUserContribs\getAllowedParams(), ApiQueryImageInfo\getAllowedParams(), ApiQueryRevisionsBase\getAllowedParams(), and ApiQueryRecentChanges\getAllowedParams().

◆ PARAM_MAX_BYTES

const ApiBase::PARAM_MAX_BYTES = StringDef::PARAM_MAX_BYTES

(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE

Deprecated:
since 1.35

Definition at line 85 of file ApiBase.php.

◆ PARAM_MAX_CHARS

const ApiBase::PARAM_MAX_CHARS = StringDef::PARAM_MAX_CHARS

(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE

Deprecated:
since 1.35

Definition at line 86 of file ApiBase.php.

◆ PARAM_MIN

const ApiBase::PARAM_MIN = IntegerDef::PARAM_MIN

(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE

Deprecated:
since 1.35

Definition at line 73 of file ApiBase.php.

Referenced by buildCommonApiParams(), ApiQueryPagePropNames\getAllowedParams(), ApiQueryMyStashedFiles\getAllowedParams(), ApiFeedRecentChanges\getAllowedParams(), ApiQueryTags\getAllowedParams(), ApiQueryPagesWithProp\getAllowedParams(), ApiQueryImages\getAllowedParams(), ApiQueryLangLinks\getAllowedParams(), ApiQueryExternalLinks\getAllowedParams(), ApiQueryAllCategories\getAllowedParams(), ApiQueryIWLinks\getAllowedParams(), ApiQueryWatchlistRaw\getAllowedParams(), ApiQueryDuplicateFiles\getAllowedParams(), ApiQueryQueryPage\getAllowedParams(), ApiQueryLangBacklinks\getAllowedParams(), ApiQueryIWBacklinks\getAllowedParams(), ApiQueryCategories\getAllowedParams(), ApiQueryRandom\getAllowedParams(), ApiQueryProtectedTitles\getAllowedParams(), ApiQueryLinks\getAllowedParams(), ApiQueryExtLinksUsage\getAllowedParams(), ApiQueryContributors\getAllowedParams(), ApiFeedWatchlist\getAllowedParams(), ApiQueryFilearchive\getAllowedParams(), ApiQueryAllLinks\getAllowedParams(), ApiQueryAllPages\getAllowedParams(), ApiQueryCategoryMembers\getAllowedParams(), ApiQueryAllUsers\getAllowedParams(), ApiQueryAllImages\getAllowedParams(), ApiQueryBlocks\getAllowedParams(), ApiQueryBacklinksprop\getAllowedParams(), ApiQueryLogEvents\getAllowedParams(), ApiQueryWatchlist\getAllowedParams(), ApiQueryDeletedrevs\getAllowedParams(), ApiQueryBacklinks\getAllowedParams(), ApiQueryUserContribs\getAllowedParams(), ApiEditPage\getAllowedParams(), ApiQueryImageInfo\getAllowedParams(), ApiQueryRevisionsBase\getAllowedParams(), ApiQueryRecentChanges\getAllowedParams(), and ApiUpload\getAllowedParams().

◆ PARAM_RANGE_ENFORCE

const ApiBase::PARAM_RANGE_ENFORCE = 'api-param-range-enforce'

(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE

Deprecated:
since 1.35

Definition at line 92 of file ApiBase.php.

Referenced by MediaWiki\Api\Validator\ApiParamValidator\checkSettings(), ApiEditPage\getAllowedParams(), and MediaWiki\Api\Validator\ApiParamValidator\normalizeSettings().

◆ PARAM_REQUIRED

◆ PARAM_SENSITIVE

const ApiBase::PARAM_SENSITIVE = ParamValidator::PARAM_SENSITIVE

(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE

Deprecated:
since 1.35

Definition at line 81 of file ApiBase.php.

Referenced by ApiCheckToken\getAllowedParams(), ApiQueryWatchlistRaw\getAllowedParams(), ApiLogin\getAllowedParams(), and ApiQueryWatchlist\getAllowedParams().

◆ PARAM_SUBMODULE_MAP

const ApiBase::PARAM_SUBMODULE_MAP = SubmoduleDef::PARAM_SUBMODULE_MAP

(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE

Deprecated:
since 1.35

Definition at line 77 of file ApiBase.php.

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

◆ PARAM_SUBMODULE_PARAM_PREFIX

const ApiBase::PARAM_SUBMODULE_PARAM_PREFIX = SubmoduleDef::PARAM_SUBMODULE_PARAM_PREFIX

(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE

Deprecated:
since 1.35

Definition at line 78 of file ApiBase.php.

Referenced by ApiPageSet\getAllowedParams().

◆ PARAM_TEMPLATE_VARS

const ApiBase::PARAM_TEMPLATE_VARS = 'param-template-vars'

(array) Indicate that this is a templated parameter, and specify replacements.

Keys are the placeholders in the parameter name and values are the names of (unprefixed) parameters from which the replacement values are taken.

For example, a parameter "foo-{ns}-{title}" could be defined with PARAM_TEMPLATE_VARS => [ 'ns' => 'namespaces', 'title' => 'titles' ]. Then a query for namespaces=0|1&titles=X|Y would support parameters foo-0-X, foo-0-Y, foo-1-X, and foo-1-Y.

All placeholders must be present in the parameter's name. Each target parameter must have PARAM_ISMULTI true. If a target is itself a templated parameter, its PARAM_TEMPLATE_VARS must be a subset of the referring parameter's, mapping the same placeholders to the same targets. A parameter cannot target itself.

Since
1.32

Definition at line 157 of file ApiBase.php.

Referenced by MediaWiki\Api\Validator\ApiParamValidator\checkSettings(), extractRequestParams(), ApiComparePages\getAllowedParams(), ApiHelp\getHelpInternal(), and ApiParamInfo\getModuleInfo().

◆ PARAM_TYPE

const ApiBase::PARAM_TYPE = ParamValidator::PARAM_TYPE

(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE

Deprecated:
since 1.35

Definition at line 70 of file ApiBase.php.

Referenced by buildCommonApiParams(), buildProfileApiParam(), ApiValidatePassword\getAllowedParams(), ApiCheckToken\getAllowedParams(), ApiFormatPhp\getAllowedParams(), ApiQueryFileRepoInfo\getAllowedParams(), ApiChangeContentModel\getAllowedParams(), ApiQueryPagePropNames\getAllowedParams(), ApiEmailUser\getAllowedParams(), ApiPatrol\getAllowedParams(), ApiTokens\getAllowedParams(), ApiResetPassword\getAllowedParams(), ApiManageTags\getAllowedParams(), ApiQueryAuthManagerInfo\getAllowedParams(), ApiMergeHistory\getAllowedParams(), ApiQueryStashImageInfo\getAllowedParams(), ApiFileRevert\getAllowedParams(), ApiQueryTokens\getAllowedParams(), ApiSetPageLanguage\getAllowedParams(), ApiUndelete\getAllowedParams(), ApiQueryMyStashedFiles\getAllowedParams(), ApiFormatJson\getAllowedParams(), ApiFeedRecentChanges\getAllowedParams(), ApiRollback\getAllowedParams(), ApiQueryTags\getAllowedParams(), ApiUnblock\getAllowedParams(), ApiQueryPagesWithProp\getAllowedParams(), ApiImport\getAllowedParams(), ApiQueryImages\getAllowedParams(), ApiQueryLangLinks\getAllowedParams(), ApiQueryExternalLinks\getAllowedParams(), ApiProtect\getAllowedParams(), ApiQueryAllCategories\getAllowedParams(), ApiQueryIWLinks\getAllowedParams(), ApiRevisionDelete\getAllowedParams(), ApiQueryWatchlistRaw\getAllowedParams(), ApiQueryDuplicateFiles\getAllowedParams(), ApiImageRotate\getAllowedParams(), ApiUserrights\getAllowedParams(), ApiQueryQueryPage\getAllowedParams(), ApiQueryLangBacklinks\getAllowedParams(), ApiQueryIWBacklinks\getAllowedParams(), ApiTag\getAllowedParams(), ApiQueryCategories\getAllowedParams(), ApiStashEdit\getAllowedParams(), ApiQueryProtectedTitles\getAllowedParams(), ApiQueryRandom\getAllowedParams(), ApiExpandTemplates\getAllowedParams(), ApiQueryLinks\getAllowedParams(), ApiBlock\getAllowedParams(), ApiQueryExtLinksUsage\getAllowedParams(), ApiQueryAllMessages\getAllowedParams(), ApiFeedContributions\getAllowedParams(), ApiSetNotificationTimestamp\getAllowedParams(), ApiOptions\getAllowedParams(), ApiDelete\getAllowedParams(), ApiQueryContributors\getAllowedParams(), ApiFeedWatchlist\getAllowedParams(), ApiQueryFilearchive\getAllowedParams(), ApiMove\getAllowedParams(), ApiLogin\getAllowedParams(), ApiCSPReport\getAllowedParams(), ApiQueryAllLinks\getAllowedParams(), ApiQueryAllPages\getAllowedParams(), ApiQueryDeletedRevisions\getAllowedParams(), ApiQueryAllRevisions\getAllowedParams(), ApiOpenSearch\getAllowedParams(), ApiQueryCategoryMembers\getAllowedParams(), ApiQueryUserInfo\getAllowedParams(), ApiQueryAllUsers\getAllowedParams(), ApiQueryAllImages\getAllowedParams(), ApiQueryBlocks\getAllowedParams(), ApiQuerySearch\getAllowedParams(), ApiQueryBacklinksprop\getAllowedParams(), ApiQueryUsers\getAllowedParams(), ApiParamInfo\getAllowedParams(), ApiQueryLogEvents\getAllowedParams(), ApiQueryAllDeletedRevisions\getAllowedParams(), ApiQueryWatchlist\getAllowedParams(), ApiQueryDeletedrevs\getAllowedParams(), ApiQueryRevisions\getAllowedParams(), ApiQuery\getAllowedParams(), ApiQueryBacklinks\getAllowedParams(), ApiQueryUserContribs\getAllowedParams(), ApiEditPage\getAllowedParams(), ApiComparePages\getAllowedParams(), ApiQueryImageInfo\getAllowedParams(), ApiQueryRevisionsBase\getAllowedParams(), ApiQueryRecentChanges\getAllowedParams(), ApiParse\getAllowedParams(), ApiQuerySiteinfo\getAllowedParams(), ApiUpload\getAllowedParams(), ApiQueryInfo\getAllowedParams(), ApiPageSet\getAllowedParams(), ApiMain\getAllowedParams(), ApiOpenSearch\getFormat(), ApiHelp\getHelpInternal(), and ApiAuthManagerHelper\getStandardParams().

◆ PARAM_VALUE_LINKS

const ApiBase::PARAM_VALUE_LINKS = 'api-param-value-links'

Deprecated and unused.

Since
1.25
Deprecated:
since 1.35

Definition at line 130 of file ApiBase.php.

Referenced by MediaWiki\Api\Validator\ApiParamValidator\checkSettings().


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