From: Timo Tijhof Date: Fri, 7 Mar 2014 17:49:50 +0000 (+0100) Subject: resourceloader: Consistently pass inDebugMode to encodeJsCall() in load.php X-Git-Tag: 1.31.0-rc.0~16655^2~1 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/rappels.php?a=commitdiff_plain;h=99a4c31425b021148a4e085cdedf67e7765c5a01;p=lhc%2Fweb%2Fwiklou.git resourceloader: Consistently pass inDebugMode to encodeJsCall() in load.php 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 --- diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index 557c1f68e2..3e001e78d5 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -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() + ); } /** diff --git a/tests/phpunit/ResourceLoaderTestCase.php b/tests/phpunit/ResourceLoaderTestCase.php index d43247192b..b37aa1aa5d 100644 --- a/tests/phpunit/ResourceLoaderTestCase.php +++ b/tests/phpunit/ResourceLoaderTestCase.php @@ -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(),