Merge "Pass in __METHOD__ to upsert() in ResourceLoaderModule::saveFileDependencies()"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoader.php
index 7fb2df2..418f532 100644 (file)
@@ -255,17 +255,6 @@ class ResourceLoader implements LoggerAwareInterface {
                // Special module that always exists
                $this->register( 'startup', [ 'class' => ResourceLoaderStartUpModule::class ] );
 
-               // Register extension modules
-               $this->register( $config->get( 'ResourceModules' ) );
-
-               // Avoid PHP 7.1 warning from passing $this by reference
-               $rl = $this;
-               Hooks::run( 'ResourceLoaderRegisterModules', [ &$rl ] );
-
-               if ( $config->get( 'EnableJavaScriptTest' ) === true ) {
-                       $this->registerTestModules();
-               }
-
                $this->setMessageBlobStore( new MessageBlobStore( $this, $this->logger ) );
        }
 
@@ -394,6 +383,9 @@ class ResourceLoader implements LoggerAwareInterface {
                }
        }
 
+       /**
+        * @internal For use by ServiceWiring only
+        */
        public function registerTestModules() {
                global $IP;
 
@@ -1119,6 +1111,10 @@ MESSAGE;
 
                                if ( !$context->getDebug() ) {
                                        $strContent = self::filter( $filter, $strContent );
+                               } else {
+                                       // In debug mode, separate each response by a new line.
+                                       // For example, between 'mw.loader.implement();' statements.
+                                       $strContent = $this->ensureNewline( $strContent );
                                }
 
                                if ( $context->getOnly() === 'scripts' ) {
@@ -1486,7 +1482,7 @@ MESSAGE;
         */
        public static function makeLoaderConditionalScript( $script ) {
                // Adds a function to lazy-created RLQ
-               return '(window.RLQ=window.RLQ||[]).push(function(){' .
+               return '(RLQ=window.RLQ||[]).push(function(){' .
                        trim( $script ) . '});';
        }
 
@@ -1500,7 +1496,7 @@ MESSAGE;
         */
        public static function makeInlineCodeWithModule( $modules, $script ) {
                // Adds an array to lazy-created RLQ
-               return '(window.RLQ=window.RLQ||[]).push(['
+               return '(RLQ=window.RLQ||[]).push(['
                        . self::encodeJsonForScript( $modules ) . ','
                        . 'function(){' . trim( $script ) . '}'
                        . ']);';
@@ -1531,7 +1527,7 @@ MESSAGE;
 
                return new WrappedString(
                        Html::inlineScript( $js, $nonce ),
-                       "<script$escNonce>(window.RLQ=window.RLQ||[]).push(function(){",
+                       "<script$escNonce>(RLQ=window.RLQ||[]).push(function(){",
                        '});</script>'
                );
        }