summaryrefslogtreecommitdiff
path: root/includes/api/ApiTokens.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-06-04 07:31:04 +0200
committerPierre Schmitz <pierre@archlinux.de>2015-06-04 07:58:39 +0200
commitf6d65e533c62f6deb21342d4901ece24497b433e (patch)
treef28adf0362d14bcd448f7b65a7aaf38650f923aa /includes/api/ApiTokens.php
parentc27b2e832fe25651ef2410fae85b41072aae7519 (diff)
Update to MediaWiki 1.25.1
Diffstat (limited to 'includes/api/ApiTokens.php')
-rw-r--r--includes/api/ApiTokens.php39
1 files changed, 17 insertions, 22 deletions
diff --git a/includes/api/ApiTokens.php b/includes/api/ApiTokens.php
index 9287fe6e..4d7fc5a0 100644
--- a/includes/api/ApiTokens.php
+++ b/includes/api/ApiTokens.php
@@ -34,9 +34,12 @@ class ApiTokens extends ApiBase {
$this->setWarning(
"action=tokens has been deprecated. Please use action=query&meta=tokens instead."
);
+ $this->logFeatureUsage( "action=tokens" );
$params = $this->extractRequestParams();
- $res = array();
+ $res = array(
+ ApiResult::META_TYPE => 'assoc',
+ );
$types = $this->getTokenTypes();
foreach ( $params['type'] as $type ) {
@@ -53,8 +56,9 @@ class ApiTokens extends ApiBase {
}
private function getTokenTypes() {
- // If we're in JSON callback mode, no tokens can be obtained
- if ( !is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) ) {
+ // If we're in a mode that breaks the same-origin policy, no tokens can
+ // be obtained
+ if ( $this->lacksSameOriginSecurity() ) {
return array();
}
@@ -62,20 +66,22 @@ class ApiTokens extends ApiBase {
if ( $types ) {
return $types;
}
- wfProfileIn( __METHOD__ );
$types = array( 'patrol' => array( 'ApiQueryRecentChanges', 'getPatrolToken' ) );
$names = array( 'edit', 'delete', 'protect', 'move', 'block', 'unblock',
'email', 'import', 'watch', 'options' );
foreach ( $names as $name ) {
$types[$name] = array( 'ApiQueryInfo', 'get' . ucfirst( $name ) . 'Token' );
}
- wfRunHooks( 'ApiTokensGetTokenTypes', array( &$types ) );
+ Hooks::run( 'ApiTokensGetTokenTypes', array( &$types ) );
ksort( $types );
- wfProfileOut( __METHOD__ );
return $types;
}
+ public function isDeprecated() {
+ return true;
+ }
+
public function getAllowedParams() {
return array(
'type' => array(
@@ -86,23 +92,12 @@ class ApiTokens extends ApiBase {
);
}
- public function getParamDescription() {
- return array(
- 'type' => 'Type of token(s) to request'
- );
- }
-
- public function getDescription() {
- return array(
- 'This module is deprecated in favor of action=query&meta=tokens.',
- 'Gets tokens for data-modifying actions.'
- );
- }
-
- protected function getExamples() {
+ protected function getExamplesMessages() {
return array(
- 'api.php?action=tokens' => 'Retrieve an edit token (the default)',
- 'api.php?action=tokens&type=email|move' => 'Retrieve an email token and a move token'
+ 'action=tokens'
+ => 'apihelp-tokens-example-edit',
+ 'action=tokens&type=email|move'
+ => 'apihelp-tokens-example-emailmove',
);
}
}