BlueSpice MediaWiki REL1_27
 All Classes Namespaces Files Functions Variables Groups Pages
ApiBase Class Reference

Inherits ContextSource.

Inherited by ApiAMCreateAccount, ApiBlock, ApiCategoryTree, ApiChangeAuthenticationData, ApiCheckToken, ApiClearHasMsg, ApiClientLogin, ApiComparePages, ApiDelete, ApiDisabled, ApiEchoMarkRead, ApiEchoMarkSeen, ApiEditPage, ApiEmailUser, ApiEmbedVideo, ApiExpandTemplates, ApiFeedContributions, ApiFeedExtendedSearch, ApiFeedRecentChanges, ApiFeedWatchlist, ApiFileRevert, ApiFlagConfig, ApiFormatBase, ApiHelp, ApiImageRotate, ApiImport, ApiLinkAccount, ApiLogin, ApiLogout, ApiMain, ApiManageTags, ApiMergeHistory, ApiMobileView, ApiMove, ApiOpenSearch, ApiOptions, ApiPageSet, ApiParamInfo, ApiParse, ApiPasteImageCheckExtension, ApiPatrol, ApiProtect, ApiPurge, ApiQuery, ApiQueryBase, ApiRemoveAuthenticationData, ApiResetPassword, ApiReview, ApiReviewActivity, ApiRevisionDelete, ApiRollback, ApiRsd, ApiScribuntoConsole, ApiSetNotificationTimestamp, ApiSidebar, ApiStabilize, ApiStashEdit, ApiTag, ApiTokens, ApiUnblock, ApiUndelete, ApiUpload, ApiUploadBase64, ApiUserrights, ApiWatch, BSApiBase, BSApiFlexiskinUpload, BSApiQueryExtendedSearch, Maps\Api\Geocode, MockApi, PFAutocompleteAPI, PFAutoeditAPI, SFAutocompleteAPI, SFAutoeditAPI, SMW\MediaWiki\Api\BrowseByProperty, SMW\MediaWiki\Api\BrowseBySubject, SMW\MediaWiki\Api\Info, SMW\MediaWiki\Api\Query, and SRFSlideShowApi.

Collaboration diagram for ApiBase:

Public Member Functions

 __construct (ApiMain $mainModule, $moduleName, $modulePrefix= '')
 
- Public Member Functions inherited from ContextSource
 getContext ()
 
 setContext (IContextSource $context)
 
 getConfig ()
 
 getRequest ()
 
 getTitle ()
 
 canUseWikiPage ()
 
 getWikiPage ()
 
 getOutput ()
 
 getUser ()
 
 getLanguage ()
 
 getSkin ()
 
 getTiming ()
 
 getStats ()
 
 msg ()
 
 exportSession ()
 

Public Attributes

const LIMIT_BIG1 = 500
 
const LIMIT_BIG2 = 5000
 
const LIMIT_SML1 = 50
 
const LIMIT_SML2 = 500
 
const GET_VALUES_FOR_HELP = 1
 
 $mModulePrefix
 
Constants for ::getAllowedParams() arrays

These constants are keys in the arrays returned by ::getAllowedParams() and accepted by ::getParameterFromSettings() that define how the parameters coming in from the request are to be interpreted.

const PARAM_DFLT = 0
 
const PARAM_ISMULTI = 1
 
const PARAM_TYPE = 2
 
const PARAM_MAX = 3
 
const PARAM_MAX2 = 4
 
const PARAM_MIN = 5
 
const PARAM_ALLOW_DUPLICATES = 6
 
const PARAM_DEPRECATED = 7
 
const PARAM_REQUIRED = 8
 
const PARAM_RANGE_ENFORCE = 9
 
const PARAM_HELP_MSG = 10
 
const PARAM_HELP_MSG_APPEND = 11
 
const PARAM_HELP_MSG_INFO = 12
 
const PARAM_VALUE_LINKS = 13
 
const PARAM_HELP_MSG_PER_VALUE = 14
 
const PARAM_SUBMODULE_MAP = 15
 
const PARAM_SUBMODULE_PARAM_PREFIX = 16
 
const PARAM_SENSITIVE = 17
 

Methods to implement

 execute ()
 
 getModuleManager ()
 
 getCustomPrinter ()
 
 getHelpUrls ()
 
 shouldCheckMaxlag ()
 
 isReadMode ()
 
 isWriteMode ()
 
 mustBePosted ()
 
 isDeprecated ()
 
 isInternal ()
 
 needsToken ()
 
 getConditionalRequestData ($condition)
 
 getExamplesMessages ()
 
 getAllowedParams ()
 
 getWebUITokenSalt (array $params)
 

Data access methods

 getModuleName ()
 
 getModulePrefix ()
 
 getMain ()
 
 isMain ()
 
 getParent ()
 
 lacksSameOriginSecurity ()
 
 getModulePath ()
 
 getModuleFromPath ($path)
 
 getResult ()
 
 getErrorFormatter ()
 
 getContinuationManager ()
 
 setContinuationManager ($manager)
 
 getDB ()
 

Parameter handling

 dynamicParameterDocumentation ()
 
 encodeParamName ($paramName)
 
 extractRequestParams ($parseLimit=true)
 
 requireOnlyOneParameter ($params, $required)
 
 requireMaxOneParameter ($params, $required)
 
 requireAtLeastOneParameter ($params, $required)
 
 requirePostedParameters ($params, $prefix= 'prefix')
 
 getTitleOrPageId ($params, $load=false)
 
 validateToken ($token, array $params)
 
 getParameter ($paramName, $parseLimit=true)
 
 getWatchlistValue ($watchlist, $titleObj, $userOption=null)
 
 getParameterFromSettings ($paramName, $paramSettings, $parseLimit)
 
 parseMultiValue ($valueName, $value, $allowMultiple, $allowedValues)
 
 validateLimit ($paramName, &$value, $min, $max, $botMax=null, $enforceLimits=false)
 
 validateTimestamp ($value, $encParamName)
 

Utility methods

 getWatchlistUser ($params)
 
 setWatch ($watch, $titleObj, $userOption=null)
 
static truncateArray (&$arr, $limit)
 
static makeMessage ($msg, IContextSource $context, array $params=null)
 

Warning and error reporting

static $messageMap
 
 setWarning ($warning)
 
 dieUsage ($description, $errorCode, $httpRespCode=0, $extradata=null)
 
 dieBlocked (Block $block)
 
 getErrorFromStatus ($status, &$extraData=null)
 
 dieStatus ($status)
 
static dieReadOnly ()
 
 dieUsageMsg ($error)
 
 dieUsageMsgOrDebug ($error)
 
 parseMsg ($error)
 
 logFeatureUsage ($feature)
 
 dieContinueUsageIf ($condition)
 
static dieDebug ($method, $message)
 

Help message generation

 getFinalDescription ()
 
 getFinalParams ($flags=0)
 
 getFinalParamDescription ()
 
 modifyHelp (array &$help, array $options, array &$tocData)
 
 getDescriptionMessage ()
 
 getHelpFlags ()
 
 getModuleSourceInfo ()
 

Deprecated

 makeHelpMsg ()
 
 makeHelpMsgParameters ()
 
 getModuleProfileName ($db=false)
 
 profileIn ()
 
 profileOut ()
 
 safeProfileOut ()
 
 getProfileTime ()
 
 profileDBIn ()
 
 profileDBOut ()
 
 getProfileDBTime ()
 
 getResultData ()
 
 getDescription ()
 
 getParamDescription ()
 
 getExamples ()
 
 makeHelpArrayToString ($prefix, $title, $input)
 
 useTransactionalTimeLimit ()
 

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

Constructor & Destructor Documentation

ApiBase::__construct ( ApiMain  $mainModule,
  $moduleName,
  $modulePrefix = '' 
)
Parameters
ApiMain$mainModule
string$moduleNameName of this module
string$modulePrefixPrefix to use for parameter names

Member Function Documentation

ApiBase::dieBlocked ( Block  $block)

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

Since
1.27
Parameters
Block$blockThe block used to generate the UsageException
Exceptions
UsageExceptionalways
ApiBase::dieContinueUsageIf (   $condition)
protected

Die with the $prefix.'badcontinue' error. This call is common enough to make it into the base method.

Parameters
bool$conditionWill only die if this value is true
Exceptions
UsageException
Since
1.21
static ApiBase::dieDebug (   $method,
  $message 
)
staticprotected

Internal code errors should be reported with this method

Parameters
string$methodMethod or function name
string$messageError message
Exceptions
MWExceptionalways
static ApiBase::dieReadOnly ( )

Helper function for readonly errors

Exceptions
UsageExceptionalways
ApiBase::dieStatus (   $status)

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

Since
1.22
Parameters
Status$status
Exceptions
UsageExceptionalways
ApiBase::dieUsage (   $description,
  $errorCode,
  $httpRespCode = 0,
  $extradata = null 
)

Throw a UsageException, which will (if uncaught) call the main module's error handler and die with an error message.

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

Output the error message related to a certain array

Parameters
array | string$errorElement of a getUserPermissionsErrors()-style array
Exceptions
UsageExceptionalways
ApiBase::dieUsageMsgOrDebug (   $error)

Will only set a warning instead of failing if the global $wgDebugAPI is set to true. Otherwise behaves exactly as dieUsageMsg().

Parameters
array | string$errorElement of a getUserPermissionsErrors()-style array
Exceptions
UsageException
Since
1.21
ApiBase::dynamicParameterDocumentation ( )

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

Returns
string|array|Message|null Return null if the module does not support additional dynamic parameters, otherwise return a message describing them.
ApiBase::encodeParamName (   $paramName)

This method mangles parameter name based on the prefix supplied to the constructor. Override this method to change parameter name during runtime

Parameters
string$paramNameParameter name
Returns
string Prefixed parameter name
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().

ApiBase::extractRequestParams (   $parseLimit = true)

Using getAllowedParams(), this function makes an array of the values provided by the user, with key being the name of the variable, and value - validated value from user or default. limits will not be parsed if $parseLimit is set to false; use this when the max limit is not definitive yet, e.g. when getting revisions.

Parameters
bool$parseLimitTrue by default
Returns
array
ApiBase::getAllowedParams ( )
protected

Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (array with PARAM_* constants as keys) Don't call this function directly: use getFinalParams() to allow hooks to modify parameters as needed.

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

Returns
array
ApiBase::getConditionalRequestData (   $condition)

Returns data for HTTP conditional request mechanisms.

Since
1.26
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.
ApiBase::getContinuationManager ( )

Get the continuation manager

Returns
ApiContinuationManager|null
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.
Returns
mixed Instance of a derived class of ApiFormatBase, or null
ApiBase::getDB ( )
protected

Gets a default slave database connection object

Returns
DatabaseBase
ApiBase::getDescription ( )
protected

Returns the description string for this module

Ignored if an i18n message exists for "apihelp-{$this->getModulePath()}-description".

Deprecated:
since 1.25
Returns
Message|string|array
ApiBase::getDescriptionMessage ( )
protected

Return the description message.

Returns
string|array|Message
ApiBase::getErrorFormatter ( )

Get the error formatter

Returns
ApiErrorFormatter
ApiBase::getErrorFromStatus (   $status,
$extraData = null 
)

Get error (as code, string) from a Status object.

Since
1.23
Parameters
Status$status
array | null&$extraDataSet if extra data from IApiMessage is available (since 1.27)
Returns
array Array of code and error string
Exceptions
MWException
ApiBase::getExamples ( )
protected

Returns usage examples for this module.

Return value as an array is either:

  • numeric keys with partial URLs ("api.php?" plus a query string) as values
  • sequential numeric keys with even-numbered keys being display-text and odd-numbered keys being partial urls
  • partial URLs as keys with display-text (string or array-to-be-joined) as values Return value as a string is the same as an array with a numeric key and that value, and boolean false means "no examples".
Deprecated:
since 1.25, use getExamplesMessages() instead
Returns
bool|string|array
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
Returns
array
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[]
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
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
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[]
ApiBase::getHelpUrls ( )

Return links to more detailed help pages about the module.

Since
1.25, returning boolean false is deprecated
Returns
string|array
ApiBase::getMain ( )

Get the main module

Returns
ApiMain
ApiBase::getModuleFromPath (   $path)

Get a module from its module path

Since
1.25
Parameters
string$path
Returns
ApiBase|null
Exceptions
UsageException
ApiBase::getModuleManager ( )

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

Since
1.21
Returns
ApiModuleManager
ApiBase::getModuleName ( )

Get the name of the module being executed by this instance

Returns
string
ApiBase::getModulePath ( )

Get the path to this module

Since
1.25
Returns
string
ApiBase::getModulePrefix ( )

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

Returns
string
ApiBase::getModuleProfileName (   $db = false)
Deprecated:
since 1.25, always returns empty string
Parameters
IDatabase | bool$db
Returns
string
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
ApiBase::getParamDescription ( )
protected

Returns an array of parameter descriptions.

For each parameter, ignored if an i18n message exists for the parameter. By default that message is "apihelp-{$this->getModulePath()}-param-{$param}", but it may be overridden using ApiBase::PARAM_HELP_MSG in the data returned by self::getFinalParams().

Deprecated:
since 1.25
Returns
array|bool False on no parameter descriptions
ApiBase::getParameter (   $paramName,
  $parseLimit = true 
)
protected

Get a value for the given parameter

Parameters
string$paramNameParameter name
bool$parseLimitSee extractRequestParams()
Returns
mixed Parameter value
ApiBase::getParameterFromSettings (   $paramName,
  $paramSettings,
  $parseLimit 
)
protected

Using the settings determine the value for the given parameter

Parameters
string$paramNameParameter name
array | mixed$paramSettingsDefault value or an array of settings using PARAM_* constants.
bool$parseLimitParse limit?
Returns
mixed Parameter value
ApiBase::getParent ( )

Get the parent of this module

Since
1.25
Returns
ApiBase|null
ApiBase::getProfileDBTime ( )
Deprecated:
since 1.25, always returns 0
Returns
float
ApiBase::getProfileTime ( )
Deprecated:
since 1.25, always returns 0
Returns
float
ApiBase::getResult ( )

Get the result object

Returns
ApiResult
ApiBase::getResultData ( )

Get the result data array (read-only)

Deprecated:
since 1.25, use $this->getResult() methods instead
Returns
array
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$params
bool | string$loadWhether load the object's state from the database:
  • false: don't load (if the pageid is given, it will still be loaded)
  • 'fromdb': load from a slave database
  • 'fromdbmaster': load from the master database
Returns
WikiPage
ApiBase::getWatchlistUser (   $params)

Gets the user for whom to get the watchlist

Parameters
array$params
Returns
User
ApiBase::getWatchlistValue (   $watchlist,
  $titleObj,
  $userOption = null 
)
protected

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

Parameters
string$watchlistValid values: 'watch', 'unwatch', 'preferences', 'nochange'
Title$titleObjThe page under consideration
string$userOptionThe user option to consider when $watchlist=preferences. If not set will use watchdefault always and watchcreations if $titleObj doesn't exist.
Returns
bool
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
Returns
string|array|null
ApiBase::isDeprecated ( )

Indicates whether this module is deprecated

Since
1.25
Returns
bool
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
Returns
bool
ApiBase::isMain ( )

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

Returns
bool
ApiBase::isReadMode ( )

Indicates whether this module requires read rights

Returns
bool
ApiBase::isWriteMode ( )

Indicates whether this module requires write mode

Returns
bool
ApiBase::lacksSameOriginSecurity ( )

Returns true if the current request breaks the same-origin policy.

For example, json with callbacks.

https://en.wikipedia.org/wiki/Same-origin_policy

Since
1.25
Returns
bool
ApiBase::logFeatureUsage (   $feature)

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

Parameters
string$featureFeature being used.
ApiBase::makeHelpArrayToString (   $prefix,
  $title,
  $input 
)
protected
Deprecated:
since 1.25
Parameters
string$prefixText to split output items
string$titleWhat is being output
string | array$input
Returns
string
ApiBase::makeHelpMsg ( )

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

Deprecated:
since 1.25
Returns
string|bool
ApiBase::makeHelpMsgParameters ( )

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

Deprecated:
since 1.25
Returns
string|bool
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$params
Returns
Message|null
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.

Parameters
string[]&$help Array 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().
ApiBase::mustBePosted ( )

Indicates whether this module must be called with a POST request

Returns
bool
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.

Returns
string|false
ApiBase::parseMsg (   $error)

Return the error message related to a certain array

Parameters
array$errorElement of a getUserPermissionsErrors()-style array
Returns
array('code' => code, 'info' => info)
ApiBase::parseMultiValue (   $valueName,
  $value,
  $allowMultiple,
  $allowedValues 
)
protected

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

Parameters
string$valueNameThe name of the parameter (for error reporting)
mixed$valueThe value being parsed
bool$allowMultipleCan $value contain more than one value separated by '|'?
string[]|null$allowedValues An array of values to check against. If null, all values are accepted.
Returns
string|string[] (allowMultiple ? an_array_of_values : a_single_value)
ApiBase::profileDBIn ( )
Deprecated:
since 1.25
ApiBase::profileDBOut ( )
Deprecated:
since 1.25
ApiBase::profileIn ( )
Deprecated:
since 1.25
ApiBase::profileOut ( )
Deprecated:
since 1.25
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
ApiBase::requireMaxOneParameter (   $params,
  $required 
)

Die if 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 at most one must be set
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
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[]$params Parameters to check
string$prefixSet to 'noprefix' to skip calling $this->encodeParamName()
ApiBase::safeProfileOut ( )
Deprecated:
since 1.25
ApiBase::setContinuationManager (   $manager)

Set the continuation manager

Parameters
ApiContinuationManager|null
ApiBase::setWarning (   $warning)

Set warning section for this module. Users should monitor this section to notice any changes in API. Multiple calls to this function will result in the warning messages being separated by newlines

Parameters
string$warningWarning message
ApiBase::setWatch (   $watch,
  $titleObj,
  $userOption = null 
)
protected

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

Parameters
string$watchValid values: 'watch', 'unwatch', 'preferences', 'nochange'
Title$titleObjThe article's title to change
string$userOptionThe user option to consider when $watch=preferences
ApiBase::shouldCheckMaxlag ( )

Indicates if this module needs maxlag to be checked

Returns
bool
static ApiBase::truncateArray ( $arr,
  $limit 
)
static

Truncate an array to a certain length.

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

Call wfTransactionalTimeLimit() if this request was POSTed

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

Validate the value against the minimum and user/bot maximum limits. Prints usage info on failure.

Parameters
string$paramNameParameter name
int$valueParameter value
int | null$minMinimum value
int | null$maxMaximum value for users
int$botMaxMaximum value for sysops/bots
bool$enforceLimitsWhether to enforce (die) if value is outside limits
ApiBase::validateTimestamp (   $value,
  $encParamName 
)
protected

Validate and normalize of parameters of type 'timestamp'

Parameters
string$valueParameter value
string$encParamNameParameter name
Returns
string Validated and normalized parameter
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

Member Data Documentation

ApiBase::$messageMap
static
Initial value:
= [
'unknownerror' => [ 'code' => 'unknownerror'

Array that maps message keys to error messages. $1 and friends are replaced.

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
const ApiBase::LIMIT_BIG1 = 500

Fast query, standard limit.

const ApiBase::LIMIT_BIG2 = 5000

Fast query, apihighlimits limit.

const ApiBase::LIMIT_SML1 = 50

Slow query, standard limit.

const ApiBase::LIMIT_SML2 = 500

Slow query, apihighlimits limit.

const ApiBase::PARAM_ALLOW_DUPLICATES = 6

(boolean) Allow the same value to be set more than once when PARAM_ISMULTI is true?

const ApiBase::PARAM_DEPRECATED = 7

(boolean) Is the parameter deprecated (will show a warning)?

const ApiBase::PARAM_DFLT = 0

(null|boolean|integer|string) Default value of the parameter.

const ApiBase::PARAM_HELP_MSG = 10

(string|array|Message) Specify an alternative i18n documentation message for this parameter. Default is apihelp-{$path}-param-{$param}.

Since
1.25
const ApiBase::PARAM_HELP_MSG_APPEND = 11

((string|array|Message)[]) Specify additional i18n messages to append to the normal message for this parameter.

Since
1.25
const ApiBase::PARAM_HELP_MSG_INFO = 12

(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
const ApiBase::PARAM_HELP_MSG_PER_VALUE = 14

((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg for ApiBase::makeMessage(). Any value not having a mapping will use apihelp-{$path}-paramvalue-{$param}-{$value}.

Since
1.25
const ApiBase::PARAM_ISMULTI = 1

(boolean) Accept multiple pipe-separated values for this parameter (e.g. titles)?

const ApiBase::PARAM_MAX = 3

(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.

const ApiBase::PARAM_MAX2 = 4

(integer) Max value allowed for the parameter for users with the apihighlimits right, for PARAM_TYPE 'limit'.

const ApiBase::PARAM_MIN = 5

(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.

const ApiBase::PARAM_RANGE_ENFORCE = 9

(boolean) For PARAM_TYPE 'integer', enforce PARAM_MIN and PARAM_MAX?

Since
1.17
const ApiBase::PARAM_REQUIRED = 8

(boolean) Is the parameter required?

Since
1.17
const ApiBase::PARAM_SENSITIVE = 17

(boolean) Is the parameter sensitive? Note 'password'-type fields are always sensitive regardless of the value of this field.

Since
1.28
const ApiBase::PARAM_SUBMODULE_MAP = 15

(string[]) When PARAM_TYPE is 'submodule', map parameter values to submodule paths. Default is to use all modules in $this->getModuleManager() in the group matching the parameter name.

Since
1.26
const ApiBase::PARAM_SUBMODULE_PARAM_PREFIX = 16

(string) When PARAM_TYPE is 'submodule', used to indicate the 'g' prefix added by ApiQueryGeneratorBase (and similar if anything else ever does that).

Since
1.26
const ApiBase::PARAM_TYPE = 2

(string|string[]) Either an array of allowed value strings, or a string type as described below. If not specified, will be determined from the type of PARAM_DFLT.

Supported string types are:

  • boolean: A boolean parameter, returned as false if the parameter is omitted and true if present (even with a falsey value, i.e. it works like HTML checkboxes). PARAM_DFLT must be boolean false, if specified. Cannot be used with PARAM_ISMULTI.
  • integer: An integer value. See also PARAM_MIN, PARAM_MAX, and PARAM_RANGE_ENFORCE.
  • limit: An integer or the string 'max'. Default lower limit is 0 (but see PARAM_MIN), and requires that PARAM_MAX and PARAM_MAX2 be specified. Cannot be used with PARAM_ISMULTI.
  • namespace: An integer representing a MediaWiki namespace.
  • NULL: Any string.
  • password: Any non-empty string. Input value is private or sensitive. <input type="password"> would be an appropriate HTML form field.
  • string: Any non-empty string, not expected to be very long or contain newlines. <input type="text"> would be an appropriate HTML form field.
  • submodule: The name of a submodule of this module, see PARAM_SUBMODULE_MAP.
  • tags: A string naming an existing, explicitly-defined tag. Should usually be used with PARAM_ISMULTI.
  • text: Any non-empty string, expected to be very long or contain newlines. <textarea> would be an appropriate HTML form field.
  • timestamp: A timestamp in any format recognized by MWTimestamp, or the string 'now' representing the current timestamp. Will be returned in TS_MW format.
  • user: A MediaWiki username or IP. Will be returned normalized but not canonicalized.
  • upload: An uploaded file. Will be returned as a WebRequestUpload object. Cannot be used with PARAM_ISMULTI.
const ApiBase::PARAM_VALUE_LINKS = 13

(string[]) When PARAM_TYPE is an array, this may be an array mapping those values to page titles which will be linked in the help.

Since
1.25

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