Merge "mediawiki.user: Simplify extension of mw.user"
[lhc/web/wiklou.git] / includes / api / ApiMain.php
index f17b874..d5cd475 100644 (file)
@@ -64,6 +64,7 @@ class ApiMain extends ApiBase {
                'rsd' => 'ApiRsd',
                'compare' => 'ApiComparePages',
                'tokens' => 'ApiTokens',
+               'checktoken' => 'ApiCheckToken',
 
                // Write modules
                'purge' => 'ApiPurge',
@@ -180,10 +181,10 @@ class ApiMain extends ApiBase {
                        // Remove all modules other than login
                        global $wgUser;
 
-                       if ( $this->getVal( 'callback' ) !== null ) {
-                               // JSON callback allows cross-site reads.
-                               // For safety, strip user credentials.
-                               wfDebug( "API: stripping user credentials for JSON callback\n" );
+                       if ( $this->lacksSameOriginSecurity() ) {
+                               // If we're in a mode that breaks the same-origin policy, strip
+                               // user credentials for security.
+                               wfDebug( "API: stripping user credentials when the same-origin policy is not applied\n" );
                                $wgUser = new User();
                                $this->getContext()->setUser( $wgUser );
                        }
@@ -214,6 +215,8 @@ class ApiMain extends ApiBase {
                $this->mModuleMgr->addModules( self::$Formats, 'format' );
                $this->mModuleMgr->addModules( $config->get( 'APIFormatModules' ), 'format' );
 
+               Hooks::run( 'ApiMain::moduleManager', array( $this->mModuleMgr ) );
+
                $this->mResult = new ApiResult( $this );
                $this->mEnableWrite = $enableWrite;