Merge "Remove old WebResponse::setCookie() calling method"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoader.php
index 0aa08be..ccf764b 100644 (file)
@@ -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;
@@ -600,10 +601,8 @@ class ResourceLoader implements LoggerAwareInterface {
         * @return string Hash
         */
        public static function makeHash( $value ) {
-               // Use base64 to output more entropy in a more compact string (default hex is only base16).
-               // The first 8 chars of a base64 encoded digest represent the same binary as
-               // the first 12 chars of a hex encoded digest.
-               return substr( base64_encode( sha1( $value, true ) ), 0, 8 );
+               $hash = hash( 'fnv132', $value );
+               return Wikimedia\base_convert( $hash, 16, 36, 7 );
        }
 
        /**
@@ -1098,7 +1097,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.' );