http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72779
Revision: 72779
Author: tparscal
Date: 2010-09-11 08:22:32 +0000 (Sat, 11 Sep 2010)
Log Message:
-----------
Added direction to ResourceLoaderContext hashing (prevents cache mangling),
dropped it from the startup module (it's not being passed on anyways - it's
really just for debugging). Also enforced sorting of parameters in URLs to make
them easier to read and less likely to miss cache unnessecarily.
Modified Paths:
--------------
trunk/phase3/includes/ResourceLoaderContext.php
trunk/phase3/includes/ResourceLoaderModule.php
trunk/phase3/resources/mediawiki/mediawiki.js
Modified: trunk/phase3/includes/ResourceLoaderContext.php
===================================================================
--- trunk/phase3/includes/ResourceLoaderContext.php 2010-09-11 08:06:38 UTC
(rev 72778)
+++ trunk/phase3/includes/ResourceLoaderContext.php 2010-09-11 08:22:32 UTC
(rev 72779)
@@ -110,7 +110,8 @@
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
Modified: trunk/phase3/includes/ResourceLoaderModule.php
===================================================================
--- trunk/phase3/includes/ResourceLoaderModule.php 2010-09-11 08:06:38 UTC
(rev 72778)
+++ trunk/phase3/includes/ResourceLoaderModule.php 2010-09-11 08:22:32 UTC
(rev 72779)
@@ -967,23 +967,21 @@
// 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
- $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
Modified: trunk/phase3/resources/mediawiki/mediawiki.js
===================================================================
--- trunk/phase3/resources/mediawiki/mediawiki.js 2010-09-11 08:06:38 UTC
(rev 72778)
+++ trunk/phase3/resources/mediawiki/mediawiki.js 2010-09-11 08:22:32 UTC
(rev 72779)
@@ -408,6 +408,20 @@
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 */
/**
@@ -468,6 +482,7 @@
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>';
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs