Merge "Allow minor edits to be filtered out of Special:Contributions"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoader.php
index c689979..09535b7 100644 (file)
@@ -88,7 +88,7 @@ class ResourceLoader implements LoggerAwareInterface {
        private $logger;
 
        /** @var string JavaScript / CSS pragma to disable minification. **/
-       const FILTER_NOMIN = ' /* @nomin */ ';
+       const FILTER_NOMIN = '/*@nomin*/';
 
        /**
         * Load information stored in the database about modules.
@@ -313,6 +313,7 @@ class ResourceLoader implements LoggerAwareInterface {
         *   not registered
         */
        public function register( $name, $info = null ) {
+               $moduleSkinStyles = $this->config->get( 'ResourceModuleSkinStyles' );
 
                // Allow multiple modules to be registered in one call
                $registrations = is_array( $name ) ? $name : [ $name => $info ];
@@ -351,7 +352,7 @@ class ResourceLoader implements LoggerAwareInterface {
 
                        // Apply custom skin-defined styles to existing modules.
                        if ( $this->isFileModule( $name ) ) {
-                               foreach ( $this->config->get( 'ResourceModuleSkinStyles' ) as $skinName => $skinStyles ) {
+                               foreach ( $moduleSkinStyles as $skinName => $skinStyles ) {
                                        // If this module already defines skinStyles for this skin, ignore $wgResourceModuleSkinStyles.
                                        if ( isset( $this->moduleInfos[$name]['skinStyles'][$skinName] ) ) {
                                                continue;
@@ -1098,7 +1099,7 @@ MESSAGE;
                                        $scripts = self::filter( 'minify-js', $scripts );
                                }
                        } else {
-                               $scripts = new XmlJsCode( "function ( $, jQuery ) {\n{$scripts}\n}" );
+                               $scripts = new XmlJsCode( "function ( $, jQuery, require, module ) {\n{$scripts}\n}" );
                        }
                } elseif ( !is_array( $scripts ) ) {
                        throw new MWException( 'Invalid scripts error. Array of URLs or string of code expected.' );
@@ -1362,8 +1363,8 @@ MESSAGE;
         * @return string
         */
        public static function makeLoaderConditionalScript( $script ) {
-               return "(window.RLQ = window.RLQ || []).push(function () {\n" .
-                       trim( $script ) . "\n} );";
+               return '(window.RLQ=window.RLQ||[]).push(function(){' .
+                       trim( $script ) . '});';
        }
 
        /**
@@ -1379,8 +1380,8 @@ MESSAGE;
                $js = self::makeLoaderConditionalScript( $script );
                return new WrappedString(
                        Html::inlineScript( $js ),
-                       "<script>(window.RLQ = window.RLQ || []).push(function () {\n",
-                       "\n} );</script>"
+                       '<script>(window.RLQ=window.RLQ||[]).push(function(){',
+                       '});</script>'
                );
        }
 
@@ -1396,7 +1397,7 @@ MESSAGE;
                        'mw.config.set',
                        [ $configuration ],
                        ResourceLoader::inDebugMode()
-               ) . ResourceLoader::FILTER_NOMIN;
+               );
        }
 
        /**