Anomie has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/251116

Change subject: API: Forwards-compatibility for ApiTokens
......................................................................

API: Forwards-compatibility for ApiTokens

To make it easier for stuff to transition, allow action=tokens to return
the new types that action=query&meta=tokens supports.

Change-Id: I83887e555d54978b392933b4a3f6dada7ed00793
---
M includes/api/ApiTokens.php
1 file changed, 13 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/16/251116/1

diff --git a/includes/api/ApiTokens.php b/includes/api/ApiTokens.php
index 4d7fc5a..f92526d 100644
--- a/includes/api/ApiTokens.php
+++ b/includes/api/ApiTokens.php
@@ -73,6 +73,19 @@
                        $types[$name] = array( 'ApiQueryInfo', 'get' . ucfirst( 
$name ) . 'Token' );
                }
                Hooks::run( 'ApiTokensGetTokenTypes', array( &$types ) );
+
+               // For forwards-compat, copy any token types from 
ApiQueryTokens that
+               // we don't already have something for.
+               $user = $this->getUser();
+               $request = $this->getRequest();
+               foreach ( ApiQueryTokens::getTokenTypeSalts() as $name => $salt 
) {
+                       if ( !isset( $types[$name] ) ) {
+                               $types[$name] = function () use ( $salt, $user, 
$request ) {
+                                       return $user->getEditToken( $salt, 
$request );
+                               };
+                       }
+               }
+
                ksort( $types );
 
                return $types;

-- 
To view, visit https://gerrit.wikimedia.org/r/251116
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I83887e555d54978b392933b4a3f6dada7ed00793
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to