Merge "API: Use message-per-value for apihelp-query+iwbacklinks-param-prop"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoader.php
index b9bc773..cd07334 100644 (file)
@@ -181,7 +181,7 @@ class ResourceLoader implements LoggerAwareInterface {
         * @param string $data Text to filter, such as JavaScript or CSS text
         * @param array $options For back-compat, can also be the boolean value for "cacheReport". Keys:
         *  - (bool) cache: Whether to allow caching this data. Default: true.
-        *  - (bool) cacheReport: Whether to include the "cache key" report comment. Default: true.
+        *  - (bool) cacheReport: Whether to include the "cache key" report comment. Default: false.
         * @return string Filtered data, or a comment containing an error message
         */
        public function filter( $filter, $data, $options = array() ) {
@@ -190,7 +190,7 @@ class ResourceLoader implements LoggerAwareInterface {
                        $options = array( 'cacheReport' => $options );
                }
                // Defaults
-               $options += array( 'cache' => true, 'cacheReport' => true );
+               $options += array( 'cache' => true, 'cacheReport' => false );
 
                // Don't filter empty content
                if ( trim( $data ) === '' ) {
@@ -1380,7 +1380,7 @@ MESSAGE;
         * @return string
         */
        public static function makeLoaderConditionalScript( $script ) {
-               return "var RLQ = RLQ || []; RLQ.push( function () {\n" . trim( $script ) . "\n} );";
+               return "window.RLQ = window.RLQ || []; window.RLQ.push( function () {\n" . trim( $script ) . "\n} );";
        }
 
        /**
@@ -1396,7 +1396,7 @@ MESSAGE;
                $js = self::makeLoaderConditionalScript( $script );
                return new WrappedString(
                        Html::inlineScript( $js ),
-                       "<script>var RLQ = RLQ || []; RLQ.push( function () {\n",
+                       "<script>window.RLQ = window.RLQ || []; window.RLQ.push( function () {\n",
                        "\n} );</script>"
                );
        }
@@ -1409,11 +1409,13 @@ MESSAGE;
         * @return string
         */
        public static function makeConfigSetScript( array $configuration ) {
-               return Xml::encodeJsCall(
-                       'mw.config.set',
-                       array( $configuration ),
-                       ResourceLoader::inDebugMode()
-               );
+               if ( ResourceLoader::inDebugMode() ) {
+                       return Xml::encodeJsCall( 'mw.config.set', array( $configuration ), true );
+               }
+
+               $config = RequestContext::getMain()->getConfig();
+               $js = Xml::encodeJsCall( 'mw.config.set', array( $configuration ), false );
+               return self::applyFilter( 'minify-js', $js, $config );
        }
 
        /**