Added direction to ResourceLoaderContext hashing (prevents cache mangling), dropped...
authorTrevor Parscal <tparscal@users.mediawiki.org>
Sat, 11 Sep 2010 08:22:32 +0000 (08:22 +0000)
committerTrevor Parscal <tparscal@users.mediawiki.org>
Sat, 11 Sep 2010 08:22:32 +0000 (08:22 +0000)
includes/ResourceLoaderContext.php
includes/ResourceLoaderModule.php
resources/mediawiki/mediawiki.js

index 1feb9fe..c9b1bd3 100644 (file)
@@ -110,7 +110,8 @@ class ResourceLoaderContext {
 
        public function getHash() {
                return isset( $this->hash ) ?
 
        public function getHash() {
                return isset( $this->hash ) ?
-                       $this->hash : $this->hash =
-                               implode( '|', array( $this->language, $this->skin, $this->user, $this->debug, $this->only ) );
+                       $this->hash : $this->hash = implode( '|', array(
+                               $this->language, $this->direction, $this->skin, $this->user, $this->debug, $this->only
+                       ) );
        }
 }
\ No newline at end of file
        }
 }
\ No newline at end of file
index afd4fad..cbe827e 100644 (file)
@@ -967,23 +967,21 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                        // Add a well-known start-up function
                        $scripts .= "window.startUp = function() { $registration mediaWiki.config.set( $config ); };";
                        // Build load query for jquery and mediawiki modules
                        // Add a well-known start-up function
                        $scripts .= "window.startUp = function() { $registration mediaWiki.config.set( $config ); };";
                        // Build load query for jquery and mediawiki modules
-                       $query = wfArrayToCGI(
-                               array(
-                                       'modules' => implode( '|', array( 'jquery', 'mediawiki' ) ),
-                                       'only' => 'scripts',
-                                       'lang' => $context->getLanguage(),
-                                       'dir' => $context->getDirection(),
-                                       'skin' => $context->getSkin(),
-                                       'debug' => $context->getDebug(),
-                                       'version' => wfTimestamp( TS_ISO_8601, round( max(
-                                               ResourceLoader::getModule( 'jquery' )->getModifiedTime( $context ),
-                                               ResourceLoader::getModule( 'mediawiki' )->getModifiedTime( $context )
-                                       ), -2 ) )
-                               )
+                       $query = array(
+                               'modules' => implode( '|', array( 'jquery', 'mediawiki' ) ),
+                               'only' => 'scripts',
+                               'lang' => $context->getLanguage(),
+                               'skin' => $context->getSkin(),
+                               'debug' => $context->getDebug() ? 'true' : 'false',
+                               'version' => wfTimestamp( TS_ISO_8601, round( max(
+                                       ResourceLoader::getModule( 'jquery' )->getModifiedTime( $context ),
+                                       ResourceLoader::getModule( 'mediawiki' )->getModifiedTime( $context )
+                               ), -2 ) )
                        );
                        );
-
+                       // Uniform query order
+                       ksort( $query );
                        // Build HTML code for loading jquery and mediawiki modules
                        // Build HTML code for loading jquery and mediawiki modules
-                       $loadScript = Html::linkedScript( "$wgLoadScript?$query" );
+                       $loadScript = Html::linkedScript( $wgLoadScript . '?' . wfArrayToCGI( $query ) );
                        // Add code to add jquery and mediawiki loading code; only if the current client is compatible
                        $scripts .= "if ( isCompatible() ) { document.write( '$loadScript' ); }";
                        // Delete the compatible function - it's not needed anymore
                        // Add code to add jquery and mediawiki loading code; only if the current client is compatible
                        $scripts .= "if ( isCompatible() ) { document.write( '$loadScript' ); }";
                        // Delete the compatible function - it's not needed anymore
index a8bc2bd..56d8f94 100644 (file)
@@ -408,6 +408,20 @@ window.mediaWiki = new ( function( $ ) {
                        that.work();
                }
                
                        that.work();
                }
                
+               function sortQuery(o) {
+                       var sorted = {}, key, a = [];
+                       for ( key in o ) {
+                               if ( o.hasOwnProperty( key ) ) {
+                                       a.push( key );
+                               }
+                       }
+                       a.sort();
+                       for ( key = 0; key < a.length; key++ ) {
+                               sorted[a[key]] = o[a[key]];
+                       }
+                       return sorted;
+               }
+               
                /* Public Methods */
                
                /**
                /* Public Methods */
                
                /**
@@ -468,6 +482,7 @@ window.mediaWiki = new ( function( $ ) {
                                function request() {
                                        var html = '';
                                        for ( var r = 0; r < requests.length; r++ ) {
                                function request() {
                                        var html = '';
                                        for ( var r = 0; r < requests.length; r++ ) {
+                                               requests[r] = sortQuery( requests[r] );
                                                // Build out the HTML
                                                var src = mediaWiki.config.get( 'wgLoadScript' ) + '?' + $.param( requests[r] );
                                                html += '<script type="text/javascript" src="' + src + '"></script>';
                                                // Build out the HTML
                                                var src = mediaWiki.config.get( 'wgLoadScript' ) + '?' + $.param( requests[r] );
                                                html += '<script type="text/javascript" src="' + src + '"></script>';