Merge "mediawiki.user: Simplify extension of mw.user"
[lhc/web/wiklou.git] / includes / api / ApiMain.php
index 34ed523..d5cd475 100644 (file)
@@ -181,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 );
                        }
@@ -215,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;