43 $this->
addWarning( [
'apiwarn-tokens-origin' ] );
55 foreach (
$params[
'type'] as $type ) {
56 $token =
self::getToken( $user, $session, $salts[$type] )->toString();
57 $fit = $this->
getResult()->addValue(
$path, $type .
'token', $token );
62 array_diff(
$params[
'type'], $done ) );
84 'rollback' =>
'rollback',
85 'userrights' =>
'userrights',
86 'login' => [
'',
'login' ],
87 'createaccount' => [
'',
'createaccount' ],
89 $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
91 $hookRunner->onApiQueryTokensRegisterTypes( $salts );
111 if ( is_array( $salt ) ) {
113 return $session->getToken( ...$salt );
122 ParamValidator::PARAM_DEFAULT =>
'csrf',
123 ParamValidator::PARAM_ISMULTI =>
true,
124 ParamValidator::PARAM_TYPE => array_keys( self::getTokenTypeSalts() ),
125 ParamValidator::PARAM_ALL =>
true,
132 'action=query&meta=tokens'
133 =>
'apihelp-query+tokens-example-simple',
134 'action=query&meta=tokens&type=watch|patrol'
135 =>
'apihelp-query+tokens-example-types',
145 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Tokens';
array $params
The job parameters.
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
addWarning( $msg, $code=null, $data=null)
Add a warning for this module.
getModuleName()
Get the name of the module being executed by this instance.
lacksSameOriginSecurity()
Returns true if the current request breaks the same-origin policy.
This is a base class for all Query modules.
setContinueEnumParameter( $paramName, $paramValue)
Set a query-continue value.
Module to fetch tokens via action=query&meta=tokens.
static getTokenTypeSalts()
Get the salts for known token types.
static getToken(User $user, MediaWiki\Session\Session $session, $salt)
Get a token from a salt.
getHelpUrls()
Return links to more detailed help pages about the module.
isReadMode()
Indicates whether this module requires read rights.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
getExamplesMessages()
Returns usage examples for this module.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.