From: Brad Jorsch Date: Wed, 4 Nov 2015 20:31:19 +0000 (-0500) Subject: API: Forwards-compatibility for ApiTokens X-Git-Tag: 1.31.0-rc.0~9101 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/rappels.php?a=commitdiff_plain;h=42e9a653090288d9b57225130c206a0559325131;p=lhc%2Fweb%2Fwiklou.git 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 --- diff --git a/includes/api/ApiTokens.php b/includes/api/ApiTokens.php index 4d7fc5a087..f92526da76 100644 --- a/includes/api/ApiTokens.php +++ b/includes/api/ApiTokens.php @@ -73,6 +73,19 @@ class ApiTokens extends ApiBase { $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;