MediaWiki
1.23.0
|
This is the main API class, used for both external and internal processing. More...
Public Member Functions | |
__construct ( $context=null, $enableWrite=false) | |
Constructs an instance of ApiMain that utilizes the module and format specified by $request. More... | |
canApiHighLimits () | |
Check whether the current user is allowed to use high limits. More... | |
createPrinterByName ( $format) | |
Create an instance of an output formatter by its name. More... | |
execute () | |
Execute api request. More... | |
getAllowedParams () | |
See ApiBase for description. More... | |
getCheck ( $name) | |
Get a boolean request value, and register the fact that the parameter was used, for logging. More... | |
getDescription () | |
See ApiBase for description. More... | |
getFormats () | |
Returns the list of supported formats in form ( 'format' => 'ClassName' ) More... | |
getModule () | |
Get the API module object. More... | |
getModuleManager () | |
Overrides to return this instance's module manager. More... | |
getModules () | |
Get the array mapping module names to class names. More... | |
getParamDescription () | |
See ApiBase for description. More... | |
getPossibleErrors () | |
getPrinter () | |
Get the result formatter object. More... | |
getResult () | |
Get the ApiResult object associated with current request. More... | |
getShowVersions () | |
Check whether the user wants us to show version information in the API help. More... | |
getUpload ( $name) | |
Get a request upload, and register the fact that it was used, for logging. More... | |
getVal ( $name, $default=null) | |
Get a request value, and register the fact that it was used, for logging. More... | |
isInternalMode () | |
Return true if the API was started by other PHP code using FauxRequest. More... | |
isReadMode () | |
makeHelpMsg () | |
Override the parent to generate help messages for all available modules. More... | |
reallyMakeHelpMsg () | |
setCacheControl ( $directives) | |
Set directives (key/value pairs) for the Cache-Control header. More... | |
setCacheMaxAge ( $maxage) | |
Set how long the response should be cached. More... | |
setCacheMode ( $mode) | |
Set the type of caching headers which will be sent. More... | |
setHelp ( $help=true) | |
Sets whether the pretty-printer should format bold and $italics$. More... | |
Public Member Functions inherited from ApiBase | |
__construct ( $mainModule, $moduleName, $modulePrefix='') | |
Constructor. More... | |
createContext () | |
Create a new RequestContext object to use e.g. More... | |
dieReadOnly () | |
Helper function for readonly errors. More... | |
dieStatus ( $status) | |
Throw a UsageException based on the errors in the Status object. More... | |
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. More... | |
dieUsageMsg ( $error) | |
Output the error message related to a certain array. More... | |
dieUsageMsgOrDebug ( $error) | |
Will only set a warning instead of failing if the global $wgDebugAPI is set to true. More... | |
encodeParamName ( $paramName) | |
This method mangles parameter name based on the prefix supplied to the constructor. More... | |
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. 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... | |
getErrorFromStatus ( $status) | |
Get error (as code, string) from a Status object. More... | |
getFinalDescription () | |
Get final module description, 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... | |
getFinalParams ( $flags=0) | |
Get final list of parameters, after hooks have had a chance to tweak it as needed. More... | |
getFinalPossibleErrors () | |
Get final list of possible errors, after hooks have had a chance to tweak it as needed. More... | |
getFinalResultProperties () | |
Get final possible result properties, after hooks have had a chance to tweak it as needed. More... | |
getHelpUrls () | |
getMain () | |
Get the main module. More... | |
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... | |
getModuleProfileName ( $db=false) | |
Get the name of the module as shown in the profiler log. More... | |
getProfileDBTime () | |
Total time the module used the database. More... | |
getProfileTime () | |
Total time the module was executed. More... | |
getRequireAtLeastOneParameterErrorMessages ( $params) | |
Generates the possible errors requireAtLeastOneParameter() can die with. More... | |
getRequireMaxOneParameterErrorMessages ( $params) | |
Generates the possible error requireMaxOneParameter() can die with. More... | |
getRequireOnlyOneParameterErrorMessages ( $params) | |
Generates the possible errors requireOnlyOneParameter() can die with. More... | |
getResultData () | |
Get the result data array (read-only) More... | |
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. More... | |
getVersion () | |
Returns a string that identifies the version of the extending class. More... | |
getWatchlistUser ( $params) | |
Gets the user for whom to get the watchlist. More... | |
isMain () | |
Returns true if this module is the main module ($this === $this->mMainModule), false otherwise. More... | |
isWriteMode () | |
Indicates whether this module requires write mode. More... | |
makeHelpMsgParameters () | |
Generates the parameter descriptions for this module, to be displayed in the module's help. More... | |
mustBePosted () | |
Indicates whether this module must be called with a POST request. More... | |
needsToken () | |
Returns whether this module requires a token to execute It is used to show possible errors in action=paraminfo see bug 25248. More... | |
parseErrors ( $errors) | |
Parses a list of errors into a standardised format. More... | |
parseMsg ( $error) | |
Return the error message related to a certain array. More... | |
profileDBIn () | |
Start module profiling. More... | |
profileDBOut () | |
End database profiling. More... | |
profileIn () | |
Start module profiling. More... | |
profileOut () | |
End module profiling. More... | |
requireAtLeastOneParameter ( $params) | |
Die if none of a certain set of parameters is set and not false. More... | |
requireMaxOneParameter ( $params) | |
Die if more than one of a certain set of parameters is set and not false. More... | |
requireOnlyOneParameter ( $params) | |
Die if none or more than one of a certain set of parameters is set and not false. More... | |
safeProfileOut () | |
When modules crash, sometimes it is needed to do a profileOut() regardless of the profiling state the module was in. More... | |
setWarning ( $warning) | |
Set warning section for this module. More... | |
shouldCheckMaxlag () | |
Indicates if this module needs maxlag to be checked. More... | |
validateLimit ( $paramName, &$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 of parameters of type 'timestamp'. 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 () | |
Get the Config object. More... | |
getContext () | |
Get the RequestContext object. More... | |
getLang () | |
Get the Language object. More... | |
getLanguage () | |
Get the Language object. More... | |
getOutput () | |
Get the OutputPage object. More... | |
getRequest () | |
Get the WebRequest object. More... | |
getSkin () | |
Get the Skin object. More... | |
getTitle () | |
Get the Title object. More... | |
getUser () | |
Get the User object. More... | |
getWikiPage () | |
Get the WikiPage object. More... | |
msg () | |
Get a Message object with context set Parameters are the same as wfMessage() More... | |
setContext (IContextSource $context) | |
Set the IContextSource object. More... | |
Static Public Member Functions | |
static | handleApiBeforeMainException (Exception $e) |
Handle an exception from the ApiBeforeMain hook. More... | |
static | makeHelpMsgHeader ( $module, $paramName) |
Static Public Member Functions inherited from ApiBase | |
static | debugPrint ( $value, $name='unknown', $backtrace=false) |
Debugging function that prints a value and an optional backtrace. More... | |
static | truncateArray (&$arr, $limit) |
Truncate an array to a certain length. More... | |
Public Attributes | |
$mModule | |
$mResult | |
$mSquidMaxage | |
const | API_DEFAULT_FORMAT = 'xmlfm' |
When no format parameter is given, this format will be used. More... | |
Public Attributes inherited from ApiBase | |
$mDBTime = 0 | |
$mModuleName | |
$mModulePrefix | |
$mModuleTime = 0 | |
const | GET_VALUES_FOR_HELP = 1 |
getAllowedParams() flag: When set, the result could take longer to generate, but should be more thorough. More... | |
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 |
Protected Member Functions | |
addFormat ( $name, $class) | |
Add or overwrite an output format for this ApiMain. More... | |
addModule ( $name, $class) | |
Add or overwrite a module in this ApiMain instance. More... | |
checkAsserts ( $params) | |
Check asserts of the user's rights. More... | |
checkExecutePermissions ( $module) | |
Check for sufficient permissions to execute. More... | |
checkMaxLag ( $module, $params) | |
Check the max lag if necessary. More... | |
encodeRequestLogValue ( $s) | |
Encode a value in a format suitable for a space-separated log line. More... | |
executeAction () | |
Execute the actual module, without any error handling. More... | |
executeActionWithErrorHandling () | |
Execute an action, and in case of an error, erase whatever partial results have been accumulated, and replace it with an error message and a help screen. More... | |
getCredits () | |
Returns an array of strings with credits for the API. More... | |
getParamsUsed () | |
Get the request parameters used in the course of the preceding execute() request. More... | |
handleCORS () | |
Check the &origin= query parameter against the Origin: HTTP header and respond appropriately. More... | |
handleException (Exception $e) | |
Handle an exception as an API response. More... | |
logRequest ( $time) | |
Log the preceding request. More... | |
printResult ( $isError) | |
Print results using the current printer. More... | |
reportUnusedParams () | |
Report unused parameters, so the client gets a hint in case it gave us parameters we don't know, for example in case of spelling mistakes or a missing 'g' prefix for generators. More... | |
sendCacheHeaders () | |
setupExecuteAction () | |
Set up for the execution. More... | |
setupExternalResponse ( $module, $params) | |
Check POST for external response and setup result printer. More... | |
setupModule () | |
Set up the module for response. More... | |
substituteResultWithError ( $e) | |
Replace the result data with the information about an exception. More... | |
Protected Member Functions inherited from ApiBase | |
dieContinueUsageIf ( $condition) | |
Die with the $prefix. More... | |
getDB () | |
Gets a default slave database connection object. More... | |
getExamples () | |
Returns usage examples for this module. More... | |
getParameter ( $paramName, $parseLimit=true) | |
Get a value for the given parameter. More... | |
getParameterFromSettings ( $paramName, $paramSettings, $parseLimit) | |
Using the settings determine the value for the given parameter. More... | |
getResultProperties () | |
Returns possible properties in the result, grouped by the value of the prop parameter that shows them. More... | |
getWatchlistValue ( $watchlist, $titleObj, $userOption=null) | |
Return true if we're to watch the page, false if not, null if no change. More... | |
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. More... | |
setWatch ( $watch, $titleObj, $userOption=null) | |
Set a watch (or unwatch) based the based on a watchlist parameter. More... | |
Static Protected Member Functions | |
static | matchOrigin ( $value, $rules, $exceptions) |
Attempt to match an Origin header against a set of rules and a set of exceptions. More... | |
static | wildcardToRegex ( $wildcard) |
Helper function to convert wildcard string into a regex '*' => '. More... | |
Static Protected Member Functions inherited from ApiBase | |
static | addTokenProperties (&$props, $tokenFunctions) |
Add token properties to the array used by getResultProperties, based on a token functions mapping. More... | |
static | dieDebug ( $method, $message) |
Internal code errors should be reported with this method. More... | |
Private Attributes | |
$mAction | |
$mCacheControl = array() | |
$mCacheMode = 'private' | |
$mCanApiHighLimits = null | |
$mEnableWrite | |
$mInternalMode | |
$mModuleMgr | |
$mParamsUsed = array() | |
ApiFormatBase | $mPrinter |
Static Private Attributes | |
static | $Formats |
List of available formats: format name => format class. More... | |
static | $Modules |
List of available modules: action name => module class. More... | |
static | $mRights |
List of user roles that are specifically relevant to the API. More... | |
Additional Inherited Members | |
Static Public Attributes inherited from ApiBase | |
static | $messageMap |
Array that maps message keys to error messages. More... | |
This is the main API class, used for both external and internal processing.
When executed, it will create the requested formatter object, instantiate and execute an object associated with the needed action, and use formatter to print results. In case of an exception, an error message will be printed using the same formatter.
To use API from another application, run it using FauxRequest object, in which case any internal exceptions will not be handled but passed up to the caller. After successful execution, use getResult() for the resulting data.
Definition at line 41 of file ApiMain.php.
ApiMain::__construct | ( | $context = null , |
|
$enableWrite = false |
|||
) |
Constructs an instance of ApiMain that utilizes the module and format specified by $request.
$context | IContextSource|WebRequest - if this is an instance of FauxRequest, errors are thrown and no printing occurs | |
bool | $enableWrite | should be set to true if the api may modify data |
Definition at line 153 of file ApiMain.php.
References ContextSource\$context, $wgUser, ContextSource\getContext(), RequestContext\getMain(), ContextSource\getRequest(), getVal(), global, ContextSource\setContext(), User, and wfDebug().
|
protected |
Add or overwrite an output format for this ApiMain.
Intended for use by extending classes who wish to add to or modify current formatters.
string | $name | The identifier for this format. |
$class | ApiFormatBase The class implementing this format. |
Definition at line 1375 of file ApiMain.php.
References $name, and getModuleManager().
|
protected |
Add or overwrite a module in this ApiMain instance.
Intended for use by extending classes who wish to add their own modules to their lexicon or override the behavior of inherent ones.
string | $name | The identifier for this module. |
$class | ApiBase The class where this module is implemented. |
Definition at line 1363 of file ApiMain.php.
References $name, and getModuleManager().
ApiMain::canApiHighLimits | ( | ) |
Check whether the current user is allowed to use high limits.
Definition at line 1327 of file ApiMain.php.
References $mCanApiHighLimits, and ContextSource\getUser().
|
protected |
Check asserts of the user's rights.
$params | array |
Definition at line 848 of file ApiMain.php.
References $params, $user, ApiBase\dieUsage(), and ContextSource\getUser().
Referenced by executeAction().
|
protected |
Check for sufficient permissions to execute.
$module | ApiBase An Api module |
Definition at line 818 of file ApiMain.php.
References $user, array(), ApiBase\dieReadOnly(), ApiBase\dieUsageMsg(), ContextSource\getUser(), User\isEveryoneAllowed(), wfReadOnly(), and wfRunHooks().
Referenced by executeAction().
|
protected |
Check the max lag if necessary.
$module | ApiBase object: Api module being used | |
array | $params | an array containing the request parameters. |
Definition at line 791 of file ApiMain.php.
References $params, $response, ApiBase\dieUsage(), ContextSource\getRequest(), global, list, and wfGetLB().
Referenced by executeAction().
ApiMain::createPrinterByName | ( | $format | ) |
Create an instance of an output formatter by its name.
$format | string |
Definition at line 316 of file ApiMain.php.
References ApiBase\dieUsage().
Referenced by setupExternalResponse(), and substituteResultWithError().
|
protected |
Encode a value in a format suitable for a space-separated log line.
Definition at line 959 of file ApiMain.php.
References $s.
Referenced by logRequest().
ApiMain::execute | ( | ) |
Execute api request.
Any errors will be handled if the API was called by the remote client.
Reimplemented from ApiBase.
Definition at line 328 of file ApiMain.php.
References executeAction(), executeActionWithErrorHandling(), ApiBase\profileIn(), and ApiBase\profileOut().
|
protected |
Execute the actual module, without any error handling.
Definition at line 893 of file ApiMain.php.
References $params, MWDebug\appendDebugInfoToApiResult(), array(), checkAsserts(), checkExecutePermissions(), checkMaxLag(), ContextSource\getContext(), getResult(), printResult(), reportUnusedParams(), setupExecuteAction(), setupExternalResponse(), setupModule(), and wfRunHooks().
Referenced by execute(), and executeActionWithErrorHandling().
|
protected |
Execute an action, and in case of an error, erase whatever partial results have been accumulated, and replace it with an error message and a help screen.
Definition at line 343 of file ApiMain.php.
References $e, $t, executeAction(), ContextSource\getRequest(), handleCORS(), handleException(), logRequest(), sendCacheHeaders(), and wfReportTime().
Referenced by execute().
ApiMain::getAllowedParams | ( | ) |
See ApiBase for description.
Reimplemented from ApiBase.
Definition at line 1078 of file ApiMain.php.
References API_DEFAULT_FORMAT, array(), ApiBase\PARAM_DFLT, and ApiBase\PARAM_TYPE.
ApiMain::getCheck | ( | $name | ) |
Get a boolean request value, and register the fact that the parameter was used, for logging.
Definition at line 992 of file ApiMain.php.
References $name, and ContextSource\getRequest().
|
protected |
Returns an array of strings with credits for the API.
Definition at line 1212 of file ApiMain.php.
References array().
Referenced by reallyMakeHelpMsg().
ApiMain::getDescription | ( | ) |
See ApiBase for description.
Reimplemented from ApiBase.
Definition at line 1149 of file ApiMain.php.
References array().
ApiMain::getFormats | ( | ) |
Returns the list of supported formats in form ( 'format' => 'ClassName' )
Definition at line 1395 of file ApiMain.php.
References getModuleManager().
ApiMain::getModule | ( | ) |
Get the API module object.
Only works after executeAction()
Definition at line 224 of file ApiMain.php.
References $mModule.
ApiMain::getModuleManager | ( | ) |
Overrides to return this instance's module manager.
Reimplemented from ApiBase.
Definition at line 1350 of file ApiMain.php.
References $mModuleMgr.
Referenced by addFormat(), addModule(), getFormats(), and getModules().
ApiMain::getModules | ( | ) |
Get the array mapping module names to class names.
Definition at line 1384 of file ApiMain.php.
References getModuleManager().
ApiMain::getParamDescription | ( | ) |
See ApiBase for description.
Reimplemented from ApiBase.
Definition at line 1113 of file ApiMain.php.
References array().
|
protected |
Get the request parameters used in the course of the preceding execute() request.
Definition at line 975 of file ApiMain.php.
Referenced by logRequest(), and reportUnusedParams().
ApiMain::getPossibleErrors | ( | ) |
Reimplemented from ApiBase.
Definition at line 1193 of file ApiMain.php.
References array().
ApiMain::getPrinter | ( | ) |
Get the result formatter object.
Only works after setupExecuteAction()
Definition at line 233 of file ApiMain.php.
References $mPrinter.
ApiMain::getResult | ( | ) |
Get the ApiResult object associated with current request.
Reimplemented from ApiBase.
Definition at line 215 of file ApiMain.php.
References $mResult.
Referenced by executeAction(), printResult(), setupExecuteAction(), setupExternalResponse(), and substituteResultWithError().
ApiMain::getShowVersions | ( | ) |
Check whether the user wants us to show version information in the API help.
Definition at line 1340 of file ApiMain.php.
References wfDeprecated().
ApiMain::getUpload | ( | $name | ) |
Get a request upload, and register the fact that it was used, for logging.
string | $name | Parameter name |
Definition at line 1005 of file ApiMain.php.
References $name, and ContextSource\getRequest().
ApiMain::getVal | ( | $name, | |
$default = null |
|||
) |
Get a request value, and register the fact that it was used, for logging.
Definition at line 982 of file ApiMain.php.
References $name, and ContextSource\getRequest().
Referenced by __construct().
|
static |
Handle an exception from the ApiBeforeMain hook.
This tries to print the exception as an API response, to be more friendly to clients. If it fails, it will rethrow the exception.
Exception | $e |
Definition at line 436 of file ApiMain.php.
References $e, false, and RequestContext\getMain().
|
protected |
Check the &origin= query parameter against the Origin: HTTP header and respond appropriately.
If no origin parameter is present, nothing happens. If an origin parameter is present but doesn't match the Origin header, a 403 status code is set and false is returned. If the parameter and the header do match, the header is checked against $wgCrossSiteAJAXdomains and $wgCrossSiteAJAXdomainExceptions, and if the origin qualifies, the appropriate CORS headers are set.
Definition at line 466 of file ApiMain.php.
References $response, array(), HttpStatus\getMessage(), ContextSource\getOutput(), ApiBase\getParameter(), ContextSource\getRequest(), global, and matchOrigin().
Referenced by executeActionWithErrorHandling().
|
protected |
Handle an exception as an API response.
Exception | $e |
Definition at line 387 of file ApiMain.php.
References $e, $response, array(), ContextSource\getRequest(), MWExceptionHandler\logException(), printResult(), MWExceptionHandler\rollbackMasterChangesAndLog(), setCacheMode(), substituteResultWithError(), and wfRunHooks().
Referenced by executeActionWithErrorHandling().
ApiMain::isInternalMode | ( | ) |
Return true if the API was started by other PHP code using FauxRequest.
Definition at line 206 of file ApiMain.php.
References $mInternalMode.
ApiMain::isReadMode | ( | ) |
|
protected |
Log the preceding request.
int | $time | Time in seconds |
Definition at line 931 of file ApiMain.php.
References $name, $s, $time, $value, as, encodeRequestLogValue(), getParamsUsed(), ContextSource\getRequest(), ContextSource\getUser(), wfDebugLog(), and wfUrlencode().
Referenced by executeActionWithErrorHandling().
ApiMain::makeHelpMsg | ( | ) |
Override the parent to generate help messages for all available modules.
Reimplemented from ApiBase.
Definition at line 1240 of file ApiMain.php.
References $retval, $wgMemc, ApiBase\getModuleName(), SpecialVersion\getVersion(), global, reallyMakeHelpMsg(), setHelp(), and wfMemcKey().
Referenced by substituteResultWithError().
|
static |
$module | ApiBase | |
string | $paramName | What type of request is this? e.g. action, query, list, prop, meta, format |
Definition at line 1312 of file ApiMain.php.
Referenced by ApiHelp\buildModuleHelp(), ApiQuery\makeHelpMsgHelper(), and reallyMakeHelpMsg().
|
staticprotected |
Attempt to match an Origin header against a set of rules and a set of exceptions.
string | $value | Origin header |
array | $rules | Set of wildcard rules |
array | $exceptions | Set of wildcard rules |
Definition at line 519 of file ApiMain.php.
References $exceptions, $value, and as.
Referenced by handleCORS().
|
protected |
Print results using the current printer.
$isError | bool |
Definition at line 1041 of file ApiMain.php.
References $mPrinter, getResult(), global, ApiBase\profileIn(), and ApiBase\setWarning().
Referenced by executeAction(), and handleException().
ApiMain::reallyMakeHelpMsg | ( | ) |
Definition at line 1263 of file ApiMain.php.
References $name, $right, as, getCredits(), User\getGroupsWithPermission(), makeHelpMsgHeader(), setHelp(), and wfMsgReplaceArgs().
Referenced by makeHelpMsg().
|
protected |
Report unused parameters, so the client gets a hint in case it gave us parameters we don't know, for example in case of spelling mistakes or a missing 'g' prefix for generators.
Definition at line 1015 of file ApiMain.php.
References $s, array(), getParamsUsed(), ContextSource\getRequest(), and ApiBase\setWarning().
Referenced by executeAction().
|
protected |
Definition at line 555 of file ApiMain.php.
References $name, $out, $response, $value, as, ContextSource\getOutput(), ApiBase\getParameter(), ContextSource\getRequest(), global, TS_RFC2822, and wfTimestamp().
Referenced by executeActionWithErrorHandling().
ApiMain::setCacheControl | ( | $directives | ) |
Set directives (key/value pairs) for the Cache-Control header.
Boolean values will be formatted as such, by including or omitting without an equals sign.
Cache control values set here will only be used if the cache mode is not private, see setCacheMode().
$directives | array |
Definition at line 305 of file ApiMain.php.
References $mCacheControl.
Referenced by setCacheMaxAge().
ApiMain::setCacheMaxAge | ( | $maxage | ) |
Set how long the response should be cached.
$maxage |
Definition at line 242 of file ApiMain.php.
References array(), and setCacheControl().
ApiMain::setCacheMode | ( | $mode | ) |
Set the type of caching headers which will be sent.
string | $mode | One of:
|
If the wiki does not allow anonymous users to read it, the mode set here will be ignored, and private caching headers will always be sent. In other words, the "public" mode is equivalent to saying that the data sent is as public as a page view.
For user-dependent data, the private mode should generally be used. The anon-public-user-private mode should only be used where there is a particularly good performance reason for caching the anonymous response, but where the response to logged-in users may differ, or may contain private data.
If this function is never called, then the default will be the private mode.
Definition at line 274 of file ApiMain.php.
References array(), User\isEveryoneAllowed(), and wfDebug().
Referenced by handleException().
ApiMain::setHelp | ( | $help = true | ) |
Sets whether the pretty-printer should format bold and $italics$.
$help | bool |
Definition at line 1231 of file ApiMain.php.
References $help.
Referenced by makeHelpMsg(), and reallyMakeHelpMsg().
|
protected |
Set up for the execution.
Definition at line 726 of file ApiMain.php.
References $params, ApiBase\dieUsage(), ApiBase\extractRequestParams(), ApiBase\getParameter(), getResult(), and global.
Referenced by executeAction().
|
protected |
Check POST for external response and setup result printer.
$module | ApiBase An Api module | |
array | $params | an array with the request parameters |
Definition at line 871 of file ApiMain.php.
References $params, array(), createPrinterByName(), ApiBase\dieUsageMsgOrDebug(), ContextSource\getRequest(), and getResult().
Referenced by executeAction().
|
protected |
Set up the module for response.
Definition at line 758 of file ApiMain.php.
References array(), ApiBase\dieUsage(), ApiBase\dieUsageMsg(), ContextSource\getContext(), ContextSource\getRequest(), and ContextSource\getUser().
Referenced by executeAction().
|
protected |
Replace the result data with the information about an exception.
Returns the error code
$e | Exception |
Definition at line 645 of file ApiMain.php.
References $e, $value, API_DEFAULT_FORMAT, array(), createPrinterByName(), ApiBase\getParameter(), ContextSource\getRequest(), getResult(), global, makeHelpMsg(), and ApiResult\setContent().
Referenced by handleException().
|
staticprotected |
Helper function to convert wildcard string into a regex '*' => '.
*?' '?' => '.'
string | $wildcard | String with wildcards |
Definition at line 544 of file ApiMain.php.
References array().
|
staticprivate |
List of available formats: format name => format class.
Definition at line 93 of file ApiMain.php.
|
private |
Definition at line 138 of file ApiMain.php.
|
private |
Definition at line 143 of file ApiMain.php.
Referenced by setCacheControl().
|
private |
Definition at line 142 of file ApiMain.php.
|
private |
Definition at line 1321 of file ApiMain.php.
Referenced by canApiHighLimits().
|
private |
Definition at line 139 of file ApiMain.php.
|
private |
Definition at line 140 of file ApiMain.php.
Referenced by isInternalMode().
ApiMain::$mModule |
Definition at line 140 of file ApiMain.php.
Referenced by getModule().
|
private |
Definition at line 137 of file ApiMain.php.
Referenced by getModuleManager().
|
staticprivate |
List of available modules: action name => module class.
Definition at line 50 of file ApiMain.php.
|
private |
Definition at line 144 of file ApiMain.php.
|
private |
Definition at line 135 of file ApiMain.php.
Referenced by getPrinter(), and printResult().
ApiMain::$mResult |
Definition at line 137 of file ApiMain.php.
Referenced by getResult().
|
staticprivate |
List of user roles that are specifically relevant to the API.
array( 'right' => array ( 'msg' => 'Some message with a $1', 'params' => array ( $someVarToSubst ) ), );
Definition at line 121 of file ApiMain.php.
ApiMain::$mSquidMaxage |
Definition at line 140 of file ApiMain.php.
const ApiMain::API_DEFAULT_FORMAT = 'xmlfm' |
When no format parameter is given, this format will be used.
Definition at line 45 of file ApiMain.php.
Referenced by getAllowedParams(), and substituteResultWithError().