Currently I'm using code like this:
// Before MW 1.20 $wgHooks['ApiTokensGetTokenTypes'][] = 'ApiTranslationReview::injectTokenFunction'; // After MW 1.20 $wgHooks['APIQueryInfoTokens'][] = 'ApiTranslationReview::injectTokenFunction'; public static function getToken() { global $wgUser; if ( !$wgUser->isAllowed( self::$right ) ) { return false; } return $wgUser->getEditToken( self::$salt ); } public static function injectTokenFunction( &$list ) { $list['translationreview'] = array( __CLASS__, 'getToken' ); return true; // Hooks must return bool }
However, I'd like to get rid of the global wgUser. Please document the best way to implement tokens for version 1.19 and above.
Version: 1.21.x
Severity: normal