MediaWiki  REL1_20
ApiBase Class Reference

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

Inheritance diagram for ApiBase:
Collaboration diagram for ApiBase:

List of all members.

Public Member Functions

 __construct ($mainModule, $moduleName, $modulePrefix= '')
 Constructor.
 createContext ()
 Create a new RequestContext object to use e.g.
 dieReadOnly ()
 Helper function for readonly errors.
 dieUsage ($description, $errorCode, $httpRespCode=0, $extradata=null)
 Throw a UsageException, which will (if uncaught) call the main module's error handler and die with an error message.
 dieUsageMsg ($error)
 Output the error message related to a certain array.
 encodeParamName ($paramName)
 This method mangles parameter name based on the prefix supplied to the constructor.
 execute ()
 Evaluates the parameters, performs the requested query, and sets up the result.
 extractRequestParams ($parseLimit=true)
 Using getAllowedParams(), this function makes an array of the values provided by the user, with key being the name of the variable, and value - validated value from user or default.
 getCustomPrinter ()
 If the module may only be used with a certain format module, it should override this method to return an instance of that formatter.
 getFinalDescription ()
 Get final module description, after hooks have had a chance to tweak it as needed.
 getFinalParamDescription ()
 Get final parameter descriptions, after hooks have had a chance to tweak it as needed.
 getFinalParams ()
 Get final list of parameters, after hooks have had a chance to tweak it as needed.
 getFinalResultProperties ()
 Get final possible result properties, after hooks have had a chance to tweak it as needed.
 getHelpUrls ()
 getMain ()
 Get the main module.
 getModuleName ()
 Get the name of the module being executed by this instance.
 getModulePrefix ()
 Get parameter prefix (usually two letters or an empty string).
 getModuleProfileName ($db=false)
 Get the name of the module as shown in the profiler log.
 getPossibleErrors ()
 Returns a list of all possible errors returned by the module.
 getProfileDBTime ()
 Total time the module used the database.
 getProfileTime ()
 Total time the module was executed.
 getRequireMaxOneParameterErrorMessages ($params)
 Generates the possible error requireMaxOneParameter() can die with.
 getRequireOnlyOneParameterErrorMessages ($params)
 Generates the possible errors requireOnlyOneParameter() can die with.
 getResult ()
 Get the result object.
 getResultData ()
 Get the result data array (read-only)
 getTitleOrPageId ($params, $load=false)
 getTitleOrPageIdErrorMessage ()
 getTokenSalt ()
 Returns the token salt if there is one, '' if the module doesn't require a salt, else false if the module doesn't need a token You have also to override needsToken() Value is passed to User::getEditToken.
 getVersion ()
 Returns a string that identifies the version of the extending class.
 getWatchlistUser ($params)
 Gets the user for whom to get the watchlist.
 isMain ()
 Returns true if this module is the main module ($this === $this->mMainModule), false otherwise.
 isReadMode ()
 Indicates whether this module requires read rights.
 isWriteMode ()
 Indicates whether this module requires write mode.
 makeHelpMsg ()
 Generates help message for this module, or false if there is no description.
 makeHelpMsg_callback ($matches)
 Callback for preg_replace_callback() call in makeHelpMsg().
 makeHelpMsgParameters ()
 Generates the parameter descriptions for this module, to be displayed in the module's help.
 mustBePosted ()
 Indicates whether this module must be called with a POST request.
 needsToken ()
 Returns whether this module requires a token to execute It is used to show possible errors in action=paraminfo see bug 25248.
 parseErrors ($errors)
 Parses a list of errors into a standardised format.
 parseMsg ($error)
 Return the error message related to a certain array.
 profileDBIn ()
 Start module profiling.
 profileDBOut ()
 End database profiling.
 profileIn ()
 Start module profiling.
 profileOut ()
 End module profiling.
 requireMaxOneParameter ($params)
 Die if more than one of a certain set of parameters is set and not false.
 requireOnlyOneParameter ($params)
 Die if none or more than one of a certain set of parameters is set and not false.
 safeProfileOut ()
 When modules crash, sometimes it is needed to do a profileOut() regardless of the profiling state the module was in.
 setWarning ($warning)
 Set warning section for this module.
 shouldCheckMaxlag ()
 Indicates if this module needs maxlag to be checked.
 validateLimit ($paramName, &$value, $min, $max, $botMax=null, $enforceLimits=false)
 Validate the value against the minimum and user/bot maximum limits.
 validateTimestamp ($value, $paramName)

Static Public Member Functions

static debugPrint ($value, $name= 'unknown', $backtrace=false)
 Debugging function that prints a value and an optional backtrace.
static getBaseVersion ()
 Returns a string that identifies the version of this class.
static getValidNamespaces ()
static truncateArray (&$arr, $limit)
 Truncate an array to a certain length.

Public Attributes

 $mDBTime = 0
 $mModuleName
 $mModulePrefix
 $mModuleTime = 0
const LIMIT_BIG1 = 500
const LIMIT_BIG2 = 5000
const LIMIT_SML1 = 50
const LIMIT_SML2 = 500
const PARAM_ALLOW_DUPLICATES = 6
const PARAM_DEPRECATED = 7
const PARAM_DFLT = 0
const PARAM_ISMULTI = 1
const PARAM_MAX = 3
const PARAM_MAX2 = 4
const PARAM_MIN = 5
const PARAM_RANGE_ENFORCE = 9
const PARAM_REQUIRED = 8
const PARAM_TYPE = 2
const PROP_LIST = 'LIST'
const PROP_NULLABLE = 1
const PROP_ROOT = 'ROOT'
const PROP_TYPE = 0

Static Public Attributes

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

Protected Member Functions

 getAllowedParams ()
 Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (array with PARAM_* constants as keys) Don't call this function directly: use getFinalParams() to allow hooks to modify parameters as needed.
 getDB ()
 getDescription ()
 Returns the description string for this module.
 getExamples ()
 Returns usage examples for this module.
 getParamDescription ()
 Returns an array of parameter descriptions.
 getParameter ($paramName, $parseLimit=true)
 Get a value for the given parameter.
 getParameterFromSettings ($paramName, $paramSettings, $parseLimit)
 Using the settings determine the value for the given parameter.
 getResultProperties ()
 Returns possible properties in the result, grouped by the value of the prop parameter that shows them.
 getWatchlistValue ($watchlist, $titleObj, $userOption=null)
 Return true if we're to watch the page, false if not, null if no change.
 makeHelpArrayToString ($prefix, $title, $input)
 parseMultiValue ($valueName, $value, $allowMultiple, $allowedValues)
 Return an array of values that were given in a 'a|b|c' notation, after it optionally validates them against the list allowed values.
 setWatch ($watch, $titleObj, $userOption=null)
 Set a watch (or unwatch) based the based on a watchlist parameter.

Static Protected Member Functions

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

Private Member Functions

 indentExampleText ($item)
 parameterNotEmpty ($x)
 Callback function used in requireOnlyOneParameter to check whether reequired parameters are set.
 warnOrDie ($msg, $enforceLimits=false)
 Adds a warning to the output, else dies.

Private Attributes

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

Detailed Description

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

The class functions are divided into several areas of functionality:

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

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

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

Definition at line 42 of file ApiBase.php.


Constructor & Destructor Documentation

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

Constructor.

Parameters:
$mainModuleApiMain object
$moduleNamestring Name of this module
$modulePrefixstring Prefix to use for parameter names

Reimplemented in ApiQueryGeneratorBase, ApiPageSet, and ApiQueryImageInfo.

Definition at line 78 of file ApiBase.php.

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


Member Function Documentation

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

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

Definition at line 624 of file ApiBase.php.

References PROP_NULLABLE, and PROP_TYPE.

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

Create a new RequestContext object to use e.g.

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

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

Definition at line 196 of file ApiBase.php.

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

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

Debugging function that prints a value and an optional backtrace.

Parameters:
$valuemixed Value to print
$namestring Description of the printed value
$backtracebool If true, print a backtrace

Definition at line 1681 of file ApiBase.php.

References $value, print, and wfBacktrace().

Helper function for readonly errors.

Definition at line 1367 of file ApiBase.php.

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

Referenced by ApiEditPage\execute().

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:
$descriptionstring One-line human-readable description of the error condition, e.g., "The API requires a valid action parameter"
$errorCodestring Brief, arbitrary, stable string to allow easy automated identification of the error, e.g., 'unknown_action'
$httpRespCodeint HTTP response code
$extradataarray Data to add to the "<error>" element; array in ApiResult format
Exceptions:
UsageException

Definition at line 1200 of file ApiBase.php.

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

Referenced by ApiQuerySiteinfo\appendDbReplLagInfo(), dieReadOnly(), dieUsageMsg(), ApiComparePages\execute(), ApiQueryStashImageInfo\execute(), ApiParse\execute(), ApiQueryDeletedrevs\execute(), ApiQueryLangLinks\execute(), ApiSetNotificationTimestamp\execute(), ApiWatch\execute(), ApiQueryIWLinks\execute(), ApiQueryFilearchive\execute(), ApiEditPage\execute(), ApiHelp\execute(), ApiOptions\execute(), ApiUpload\execute(), ApiUnblock\execute(), ApiQueryBlocks\execute(), ApiQueryImageInfo\execute(), ApiDisabled\execute(), ApiQueryContributions\execute(), ApiQueryLogEvents\execute(), ApiFeedContributions\execute(), ApiBlock\execute(), ApiQueryAllUsers\execute(), ApiFeedWatchlist\execute(), ApiQueryRevisions\execute(), ApiQueryInfo\execute(), ApiPageSet\execute(), ApiQueryAllPages\executeGenerator(), ApiQueryAllImages\executeGenerator(), ApiQueryRevisions\extractRowInfo(), getParameterFromSettings(), ApiParse\getParsedSectionOrText(), ApiQueryImageInfo\getScale(), ApiParse\getSectionText(), getWatchlistUser(), ApiQueryImageInfo\mergeThumbParams(), parseMultiValue(), ApiQueryContributions\prepareQuery(), ApiQueryBase\prepareUrlQuerySearchString(), ApiQueryContributions\prepareUsername(), ApiQueryBlocks\prepareUsername(), requireMaxOneParameter(), requireOnlyOneParameter(), ApiComparePages\revisionOrTitleOrId(), ApiQueryIWBacklinks\run(), ApiQueryImages\run(), ApiQueryLangBacklinks\run(), ApiQuerySearch\run(), ApiQueryWatchlistRaw\run(), ApiQueryAllLinks\run(), ApiQueryAllCategories\run(), ApiQueryDuplicateFiles\run(), ApiQueryCategories\run(), ApiQueryCategoryMembers\run(), ApiQueryWatchlist\run(), ApiQueryAllPages\run(), ApiQueryAllImages\run(), ApiQueryLinks\run(), ApiQueryRecentChanges\run(), validateTimestamp(), and warnOrDie().

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:
$paramNamestring Parameter name
Returns:
string Prefixed parameter name

Reimplemented in ApiQueryGeneratorBase.

Definition at line 651 of file ApiBase.php.

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

ApiBase::execute ( ) [abstract]

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

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

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

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

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

ApiBase::extractRequestParams ( parseLimit = true)

Using getAllowedParams(), this function makes an array of the values provided by the user, with key being the name of the variable, and value - validated value from user or default.

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

Parameters:
$parseLimitBoolean: true by default
Returns:
array

Definition at line 664 of file ApiBase.php.

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

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

ApiBase::getAllowedParams ( ) [protected]

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

Returns:
array|bool

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

Definition at line 550 of file ApiBase.php.

Referenced by getFinalParams().

static ApiBase::getBaseVersion ( ) [static]

Returns a string that identifies the version of this class.

Returns:
string

Reimplemented in ApiQueryBase, and ApiFormatBase.

Definition at line 1694 of file ApiBase.php.

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

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

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

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

Definition at line 235 of file ApiBase.php.

ApiBase::getDB ( ) [protected]
Returns:
DatabaseBase

Reimplemented in ApiQueryBase, ApiQuery, and ApiQueryAllImages.

Definition at line 1671 of file ApiBase.php.

References wfGetDB().

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

ApiBase::getDescription ( ) [protected]

Returns the description string for this module.

Returns:
mixed string or array of strings

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

Definition at line 531 of file ApiBase.php.

Referenced by getFinalDescription().

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

Returns:
array|bool False on no parameters

Definition at line 639 of file ApiBase.php.

References getDescription(), and wfRunHooks().

Referenced by makeHelpMsg().

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

Returns:
array|bool False on no parameter descriptions

Definition at line 582 of file ApiBase.php.

References getParamDescription(), and wfRunHooks().

Referenced by makeHelpMsgParameters().

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

Returns:
array|Bool False on no parameters

Definition at line 570 of file ApiBase.php.

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

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

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

Returns:
array

Definition at line 614 of file ApiBase.php.

References getResultProperties(), and wfRunHooks().

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

Returns:
string

Definition at line 122 of file ApiBase.php.

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

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

Returns:
string

Definition at line 130 of file ApiBase.php.

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

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

Parameters:
$dbDatabaseBase|bool
Returns:
string

Definition at line 141 of file ApiBase.php.

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

Returns an array of parameter descriptions.

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

Returns:
array|bool False on no parameter descriptions

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

Definition at line 560 of file ApiBase.php.

Referenced by getFinalParamDescription().

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

Get a value for the given parameter.

Parameters:
$paramNamestring Parameter name
$parseLimitbool see extractRequestParams()
Returns:
mixed Parameter value

Definition at line 687 of file ApiBase.php.

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

Referenced by ApiMain\sendCacheHeaders().

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

Using the settings determine the value for the given parameter.

Parameters:
$paramNameString: parameter name
$paramSettingsarray|mixed default value or an array of settings using PARAM_* constants.
$parseLimitBoolean: parse limit?
Returns:
mixed Parameter value

Definition at line 897 of file ApiBase.php.

References $title, $value, dieDebug(), dieUsage(), dieUsageMsg(), encodeParamName(), getMain(), getModuleName(), ContextSource\getRequest(), getResult(), getValidNamespaces(), Title\makeTitleSafe(), PARAM_ALLOW_DUPLICATES, PARAM_DEPRECATED, PARAM_DFLT, PARAM_ISMULTI, PARAM_MAX, PARAM_MAX2, PARAM_MIN, PARAM_RANGE_ENFORCE, PARAM_REQUIRED, PARAM_TYPE, parseMultiValue(), setWarning(), validateLimit(), and validateTimestamp().

Referenced by extractRequestParams(), and getParameter().

Total time the module used the database.

Returns:
float

Definition at line 1661 of file ApiBase.php.

References dieDebug().

Total time the module was executed.

Returns:
float

Definition at line 1612 of file ApiBase.php.

References dieDebug().

Generates the possible error requireMaxOneParameter() can die with.

Parameters:
$paramsarray
Returns:
array

Definition at line 752 of file ApiBase.php.

References $params, and getModulePrefix().

Referenced by ApiSetNotificationTimestamp\getPossibleErrors().

Get the result object.

Returns:
ApiResult

Reimplemented in ApiMain.

Definition at line 170 of file ApiBase.php.

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

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

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

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

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

Returns:
array|bool False on no properties

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

Definition at line 604 of file ApiBase.php.

Referenced by getFinalResultProperties().

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

Definition at line 769 of file ApiBase.php.

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

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

Returns the token salt if there is one, '' if the module doesn't require a salt, else false if the module doesn't need a token You have also to override needsToken() Value is passed to User::getEditToken.

Returns:
bool|string|array

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

Definition at line 1472 of file ApiBase.php.

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

Definition at line 823 of file ApiBase.php.

References wfDeprecated().

Referenced by getParameterFromSettings().

ApiBase::getVersion ( ) [abstract]

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

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

Returns:
string

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

Referenced by makeHelpMsg().

Gets the user for whom to get the watchlist.

Parameters:
$paramsarray
Returns:
User

Definition at line 1482 of file ApiBase.php.

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

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

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

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

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

Definition at line 836 of file ApiBase.php.

References ContextSource\getUser().

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

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

Definition at line 328 of file ApiBase.php.

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

Returns:
bool

Definition at line 162 of file ApiBase.php.

Referenced by __construct(), and getResult().

Indicates whether this module requires read rights.

Returns:
bool

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

Definition at line 1435 of file ApiBase.php.

Referenced by getPossibleErrors(), and makeHelpMsg().

Indicates whether this module requires write mode.

Returns:
bool

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

Definition at line 1442 of file ApiBase.php.

Referenced by getPossibleErrors(), and makeHelpMsg().

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

Definition at line 338 of file ApiBase.php.

References $input, and $title.

Referenced by makeHelpMsg().

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

Returns:
mixed string or false

Reimplemented in ApiMain, and ApiQuery.

Definition at line 243 of file ApiBase.php.

References getExamples(), getFinalDescription(), getHelpUrls(), getMain(), getVersion(), isReadMode(), isWriteMode(), makeHelpArrayToString(), makeHelpMsgParameters(), and mustBePosted().

Callback for preg_replace_callback() call in makeHelpMsg().

Replaces a source file name with a link to ViewVC

Parameters:
$matchesarray
Returns:
string

Definition at line 496 of file ApiBase.php.

References $file, $matches, $path, $wgAutoloadClasses, and $wgAutoloadLocalClasses.

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

Returns:
string or false

Reimplemented in ApiQuery.

Definition at line 361 of file ApiBase.php.

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

Referenced by makeHelpMsg().

Indicates whether this module must be called with a POST request.

Returns:
bool

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

Definition at line 1450 of file ApiBase.php.

Referenced by getPossibleErrors(), and makeHelpMsg().

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

Returns:
bool

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

Definition at line 1460 of file ApiBase.php.

Referenced by getPossibleErrors().

ApiBase::parameterNotEmpty ( x) [private]

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

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

Definition at line 814 of file ApiBase.php.

ApiBase::parseErrors ( errors)

Parses a list of errors into a standardised format.

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

Definition at line 1550 of file ApiBase.php.

References parseMsg().

ApiBase::parseMsg ( error)

Return the error message related to a certain array.

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

Definition at line 1392 of file ApiBase.php.

References wfMsgReplaceArgs().

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

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

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

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

Definition at line 1063 of file ApiBase.php.

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

Referenced by getParameterFromSettings().

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

Parameters:
$paramsarray

Definition at line 733 of file ApiBase.php.

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

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

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

Parameters:
$paramsarray of parameter names

Definition at line 697 of file ApiBase.php.

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

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

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

This method does such cleanup.

Definition at line 1599 of file ApiBase.php.

References profileDBOut(), and profileOut().

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:
$warningstring Warning message

Definition at line 208 of file ApiBase.php.

References $result, getModuleName(), getResult(), and ApiResult\setContent().

Referenced by ApiResult\addValue(), ApiFormatXml\addXslt(), ApiTokens\execute(), ApiPurge\execute(), ApiOptions\execute(), ApiQueryDisabled\execute(), ApiQueryUsers\execute(), ApiQueryRevisions\execute(), ApiPageSet\execute(), ApiQueryInfo\extractPageInfo(), ApiQueryRecentChanges\extractRowInfo(), ApiQueryRevisions\extractRowInfo(), getParameterFromSettings(), ApiQueryImageInfo\mergeThumbParams(), parseMultiValue(), ApiQueryImages\run(), ApiQueryCategories\run(), ApiQueryLinks\run(), and warnOrDie().

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

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

Parameters:
$watchString Valid values: 'watch', 'unwatch', 'preferences', 'nochange'
$titleObjTitle the article's title to change
$userOptionString The user option to consider when $watch=preferences

Definition at line 874 of file ApiBase.php.

References $user, $value, WatchAction\doUnwatch(), WatchAction\doWatch(), ContextSource\getUser(), and getWatchlistValue().

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

Indicates if this module needs maxlag to be checked.

Returns:
bool

Reimplemented in ApiQuery, and ApiHelp.

Definition at line 1427 of file ApiBase.php.

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

Truncate an array to a certain length.

Parameters:
$arrarray Array to truncate
$limitint Maximum length
Returns:
bool True if the array was truncated, false otherwise

Definition at line 1179 of file ApiBase.php.

References $limit.

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

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

Prints usage info on failure.

Parameters:
$paramNamestring Parameter name
$valueint Parameter value
$minint|null Minimum value
$maxint|null Maximum value for users
$botMaxint Maximum value for sysops/bots
$enforceLimitsBoolean Whether to enforce (die) if value is outside limits

Definition at line 1116 of file ApiBase.php.

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

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

ApiBase::validateTimestamp ( value,
paramName 
)
Parameters:
$valuestring
$paramNamestring
Returns:
string

Definition at line 1151 of file ApiBase.php.

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

Referenced by getParameterFromSettings().

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

Adds a warning to the output, else dies.

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

Definition at line 1165 of file ApiBase.php.

References dieUsage(), and setWarning().

Referenced by validateLimit().


Member Data Documentation

ApiBase::$mDBTime = 0

Definition at line 1622 of file ApiBase.php.

ApiBase::$mDBTimeIn = 0 [private]

Profiling: database execution time.

Definition at line 1622 of file ApiBase.php.

ApiBase::$messageMap [static]

Array that maps message keys to error messages.

$1 and friends are replaced.

Definition at line 1208 of file ApiBase.php.

ApiBase::$mMainModule [private]

Definition at line 69 of file ApiBase.php.

ApiBase::$mModuleName

Definition at line 69 of file ApiBase.php.

ApiBase::$mModulePrefix

Definition at line 69 of file ApiBase.php.

ApiBase::$mModuleTime = 0

Definition at line 1566 of file ApiBase.php.

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

Definition at line 70 of file ApiBase.php.

ApiBase::$mTimeIn = 0 [private]

Profiling: total module execution time.

Definition at line 1566 of file ApiBase.php.

Definition at line 46 of file ApiBase.php.

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

Definition at line 47 of file ApiBase.php.

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

Since:
1.17

Definition at line 57 of file ApiBase.php.

Referenced by getParameterFromSettings().

Definition at line 48 of file ApiBase.php.

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


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