Ignore DBPerformance thresholds in Special:ConfirmEmail
[lhc/web/wiklou.git] / includes / OutputPage.php
index dd7b90a..073762a 100644 (file)
@@ -2702,14 +2702,14 @@ class OutputPage extends ContextSource {
                }
 
                $ret .= Html::element( 'title', null, $this->getHTMLTitle() ) . "\n";
+               $ret .= $this->getInlineHeadScripts() . "\n";
+               $ret .= $this->buildCssLinks() . "\n";
+               $ret .= $this->getExternalHeadScripts() . "\n";
 
                foreach ( $this->getHeadLinksArray() as $item ) {
                        $ret .= $item . "\n";
                }
 
-               $ret .= $this->buildCssLinks() . "\n";
-               $ret .= $this->getHeadScripts() . "\n";
-
                foreach ( $this->mHeadItems as $item ) {
                        $ret .= $item . "\n";
                }
@@ -2878,7 +2878,7 @@ class OutputPage extends ContextSource {
 
                                // Inline private modules. These can't be loaded through load.php for security
                                // reasons, see bug 34907. Note that these modules should be loaded from
-                               // getHeadScripts() before the first loader call. Otherwise other modules can't
+                               // getExternalHeadScripts() before the first loader call. Otherwise other modules can't
                                // properly use them as dependencies (bug 30914)
                                if ( $group === 'private' ) {
                                        if ( $only == ResourceLoaderModule::TYPE_STYLES ) {
@@ -2909,7 +2909,8 @@ class OutputPage extends ContextSource {
 
                                // Automatically select style/script elements
                                if ( $only === ResourceLoaderModule::TYPE_STYLES ) {
-                                       $link = Html::linkedStyle( $url );
+                                       $media = $group === 'print' ? 'print' : 'all';
+                                       $link = Html::linkedStyle( $url, $media );
                                } else {
                                        if ( $context->getRaw() || $isRaw ) {
                                                // Startup module can't load itself, needs to use <script> instead of mw.loader.load
@@ -2923,6 +2924,15 @@ class OutputPage extends ContextSource {
                                                        Xml::encodeJsCall( 'mw.loader.load', array( $url ) )
                                                );
                                        }
+
+                                       // For modules requested directly in the html via <script> or mw.loader.load
+                                       // tell mw.loader they are being loading to prevent duplicate requests.
+                                       foreach ( $grpModules as $key => $module ) {
+                                               // Don't output state=loading for the startup module.
+                                               if ( $key !== 'startup' ) {
+                                                       $links['states'][$key] = 'loading';
+                                               }
+                                       }
                                }
 
                                if ( $group == 'noscript' ) {
@@ -2971,6 +2981,30 @@ class OutputPage extends ContextSource {
         * @return string HTML fragment
         */
        function getHeadScripts() {
+               return $this->getInlineHeadScripts() . "\n" . $this->getExternalHeadScripts();
+       }
+
+       /**
+        * <script src="..."> tags for "<head>". This is the startup module
+        * and other modules marked with position 'top'.
+        *
+        * @return string HTML fragment
+        */
+       function getExternalHeadScripts() {
+               $links = array();
+
+               // Startup - this provides the client with the module manifest and loads jquery and mediawiki base modules
+               $links[] = $this->makeResourceLoaderLink( 'startup', ResourceLoaderModule::TYPE_SCRIPTS );
+
+               return self::getHtmlFromLoaderLinks( $links );
+       }
+
+       /**
+        * <script>...</script> tags to put in "<head>".
+        *
+        * @return string HTML fragment
+        */
+       function getInlineHeadScripts() {
                $links = array();
 
                // Client profile classes for <html>. Allows for easy hiding/showing of UI components.
@@ -2984,9 +3018,6 @@ class OutputPage extends ContextSource {
                        . '.replace( /(^|\s)client-nojs(\s|$)/, "$1client-js$2" );'
                );
 
-               // Startup - this provides the client with the module manifest and loads jquery and mediawiki base modules
-               $links[] = $this->makeResourceLoaderLink( 'startup', ResourceLoaderModule::TYPE_SCRIPTS );
-
                // Load config before anything else
                $links[] = ResourceLoader::makeInlineScript(
                        ResourceLoader::makeConfigSetScript( $this->getJSVars() )
@@ -3015,22 +3046,16 @@ class OutputPage extends ContextSource {
                        ResourceLoaderModule::TYPE_SCRIPTS
                );
 
-               if ( $this->getConfig()->get( 'ResourceLoaderExperimentalAsyncLoading' ) ) {
-                       $links[] = $this->getScriptsForBottomQueue();
-               }
-
                return self::getHtmlFromLoaderLinks( $links );
        }
 
        /**
-        * JS stuff to put at the 'bottom', which can either be the bottom of the
-        * "<body>" or the bottom of the "<head>" depending on
-        * $wgResourceLoaderExperimentalAsyncLoading: modules marked with position
-        * 'bottom', legacy scripts ($this->mScripts), user preferences, site JS
-        * and user JS.
+        * JS stuff to put at the 'bottom', which goes at the bottom of the `<body>`.
+        * These are modules marked with position 'bottom', legacy scripts ($this->mScripts),
+        * site JS, and user JS.
         *
         * @param bool $unused Previously used to let this method change its output based
-        *  on whether it was called by getHeadScripts() or getBottomScripts().
+        *  on whether it was called by getExternalHeadScripts() or getBottomScripts().
         * @return string
         */
        function getScriptsForBottomQueue( $unused = null ) {
@@ -3111,11 +3136,7 @@ class OutputPage extends ContextSource {
                // In case the skin wants to add bottom CSS
                $this->getSkin()->setupSkinUserCss( $this );
 
-               if ( $this->getConfig()->get( 'ResourceLoaderExperimentalAsyncLoading' ) ) {
-                       // Already handled by getHeadScripts()
-                       return '';
-               }
-               return  $this->getScriptsForBottomQueue();
+               return $this->getScriptsForBottomQueue();
        }
 
        /**