resourceloader: Consistently pass inDebugMode to encodeJsCall() in load.php
authorTimo Tijhof <krinklemail@gmail.com>
Fri, 7 Mar 2014 17:49:50 +0000 (18:49 +0100)
committerKrinkle <krinklemail@gmail.com>
Fri, 7 Mar 2014 19:11:19 +0000 (19:11 +0000)
Still quite a few were being minified unconditinally. This is in
preparation for adding unit tests for the startup module where
it'll make reading the unit tests (and looking at the diff in case
of a failure) a lot easier if the strings aren't minified.

Change-Id: Ia06787e0ce608fcafac4596c980606d06107f517

includes/resourceloader/ResourceLoader.php
tests/phpunit/ResourceLoaderTestCase.php

index 557c1f6..3e001e7 100644 (file)
@@ -933,7 +933,11 @@ class ResourceLoader {
         * @return string
         */
        public static function makeMessageSetScript( $messages ) {
-               return Xml::encodeJsCall( 'mw.messages.set', array( (object)$messages ) );
+               return Xml::encodeJsCall(
+                       'mw.messages.set',
+                       array( (object)$messages ),
+                       ResourceLoader::inDebugMode()
+               );
        }
 
        /**
@@ -988,9 +992,17 @@ class ResourceLoader {
         */
        public static function makeLoaderStateScript( $name, $state = null ) {
                if ( is_array( $name ) ) {
-                       return Xml::encodeJsCall( 'mw.loader.state', array( $name ) );
+                       return Xml::encodeJsCall(
+                               'mw.loader.state',
+                               array( $name ),
+                               ResourceLoader::inDebugMode()
+                       );
                } else {
-                       return Xml::encodeJsCall( 'mw.loader.state', array( $name, $state ) );
+                       return Xml::encodeJsCall(
+                               'mw.loader.state',
+                               array( $name, $state ),
+                               ResourceLoader::inDebugMode()
+                       );
                }
        }
 
@@ -1013,7 +1025,9 @@ class ResourceLoader {
                $script = str_replace( "\n", "\n\t", trim( $script ) );
                return Xml::encodeJsCall(
                        "( function ( name, version, dependencies, group, source ) {\n\t$script\n} )",
-                       array( $name, $version, $dependencies, $group, $source ) );
+                       array( $name, $version, $dependencies, $group, $source ),
+                       ResourceLoader::inDebugMode()
+               );
        }
 
        /**
@@ -1045,11 +1059,18 @@ class ResourceLoader {
                $dependencies = null, $group = null, $source = null
        ) {
                if ( is_array( $name ) ) {
-                       return Xml::encodeJsCall( 'mw.loader.register', array( $name ) );
+                       return Xml::encodeJsCall(
+                               'mw.loader.register',
+                               array( $name ),
+                               ResourceLoader::inDebugMode()
+                       );
                } else {
                        $version = (int)$version > 1 ? (int)$version : 1;
-                       return Xml::encodeJsCall( 'mw.loader.register',
-                               array( $name, $version, $dependencies, $group, $source ) );
+                       return Xml::encodeJsCall(
+                               'mw.loader.register',
+                               array( $name, $version, $dependencies, $group, $source ),
+                               ResourceLoader::inDebugMode()
+                       );
                }
        }
 
@@ -1070,9 +1091,17 @@ class ResourceLoader {
         */
        public static function makeLoaderSourcesScript( $id, $properties = null ) {
                if ( is_array( $id ) ) {
-                       return Xml::encodeJsCall( 'mw.loader.addSource', array( $id ) );
+                       return Xml::encodeJsCall(
+                               'mw.loader.addSource',
+                               array( $id ),
+                               ResourceLoader::inDebugMode()
+                       );
                } else {
-                       return Xml::encodeJsCall( 'mw.loader.addSource', array( $id, $properties ) );
+                       return Xml::encodeJsCall(
+                               'mw.loader.addSource',
+                               array( $id, $properties ),
+                               ResourceLoader::inDebugMode()
+                       );
                }
        }
 
@@ -1097,7 +1126,11 @@ class ResourceLoader {
         * @return string
         */
        public static function makeConfigSetScript( array $configuration ) {
-               return Xml::encodeJsCall( 'mw.config.set', array( $configuration ), ResourceLoader::inDebugMode() );
+               return Xml::encodeJsCall(
+                       'mw.config.set',
+                       array( $configuration ),
+                       ResourceLoader::inDebugMode()
+               );
        }
 
        /**
index d432471..b37aa1a 100644 (file)
@@ -19,6 +19,12 @@ abstract class ResourceLoaderTestCase extends MediaWikiTestCase {
                parent::setUp();
 
                $this->setMwGlobals( array(
+                       // For ResourceLoader::inDebugMode since it doesn't have context
+                       'wgResourceLoaderDebug' => true,
+
+                       // Avoid influence from wgInvalidateCacheOnLocalSettingsChange
+                       'wgCacheEpoch' => '20140101000000',
+
                        // For ResourceLoader::__construct()
                        'wgResourceLoaderSources' => array(),