Merge "Displaying search results for multiple wikis"
[lhc/web/wiklou.git] / includes / api / ApiTokens.php
index f7290af..4d7fc5a 100644 (file)
@@ -37,7 +37,9 @@ class ApiTokens extends ApiBase {
                $this->logFeatureUsage( "action=tokens" );
 
                $params = $this->extractRequestParams();
-               $res = array();
+               $res = array(
+                       ApiResult::META_TYPE => 'assoc',
+               );
 
                $types = $this->getTokenTypes();
                foreach ( $params['type'] as $type ) {
@@ -54,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();
                }
 
@@ -63,7 +66,6 @@ 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' );
@@ -72,7 +74,6 @@ class ApiTokens extends ApiBase {
                }
                Hooks::run( 'ApiTokensGetTokenTypes', array( &$types ) );
                ksort( $types );
-               wfProfileOut( __METHOD__ );
 
                return $types;
        }