r23924 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23923‎ | r23924 | r23925 >
Date:21:39, 9 July 2007
Author:brion
Status:old
Tags:
Comment:
* (bug 10316) Prevent inconsistent cached skin settings in gen=js by setting the intended skin directly in the URL.

Not sure whether the global 'skin' and 'stylepath' settings should be removed from the gen=js or from the inline vars, but this fixes the inconsistency between them.
It also fixes the inconsistent use of skin-specific .js files (MediaWiki:Monobook.js loaded for wrong skin, etc).
By passing the skin name directly in the gen=js, we ensure both that we have the correct skin information cached
and that you'll get the JS along with useskin= on an HTML page.

Normally useskin= prevents caching, but RawPage handles its own caching headers, so this doesn't cause any problems here. Doesn't seem to be a performance problem in my quick ab testing either.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Skin.php (modified) (history)
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SkinTemplate.php
@@ -285,11 +285,11 @@
286286 $tpl->setRef( 'userjsprev', $this->userjsprev);
287287 global $wgUseSiteJs;
288288 if ($wgUseSiteJs) {
289 - if($this->loggedin) {
290 - $tpl->set( 'jsvarurl', self::makeUrl('-','action=raw&smaxage=0&gen=js') );
291 - } else {
292 - $tpl->set( 'jsvarurl', self::makeUrl('-','action=raw&gen=js') );
293 - }
 289+ $jsCache = $this->loggedin ? '&smaxage=0' : '';
 290+ $tpl->set( 'jsvarurl',
 291+ self::makeUrl('-',
 292+ "action=raw$jsCache&gen=js&useskin=" .
 293+ urlencode( $this->getSkinName() ) ) );
294294 } else {
295295 $tpl->set('jsvarurl', false);
296296 }
Index: trunk/phase3/includes/Skin.php
@@ -354,11 +354,12 @@
355355 $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n";
356356 global $wgUseSiteJs;
357357 if ($wgUseSiteJs) {
358 - if ($wgUser->isLoggedIn()) {
359 - $r .= "<script type=\"$wgJsMimeType\" src=\"".htmlspecialchars(self::makeUrl('-','action=raw&smaxage=0&gen=js'))."\"><!-- site js --></script>\n";
360 - } else {
361 - $r .= "<script type=\"$wgJsMimeType\" src=\"".htmlspecialchars(self::makeUrl('-','action=raw&gen=js'))."\"><!-- site js --></script>\n";
362 - }
 358+ $jsCache = $wgUser->isLoggedIn() ? '&smaxage=0' : '';
 359+ $r .= "<script type=\"$wgJsMimeType\" src=\"".
 360+ htmlspecialchars(self::makeUrl('-',
 361+ "action=raw$jsCache&gen=js&useskin=" .
 362+ urlencode( $this->getSkinName() ) ) ) .
 363+ "\"><!-- site js --></script>\n";
363364 }
364365 if( $allowUserJs && $wgUser->isLoggedIn() ) {
365366 $userpage = $wgUser->getUserPage();
@@ -427,7 +428,8 @@
428429
429430 global $wgStylePath;
430431 $s = "/* generated javascript */\n";
431 - $s .= "var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';";
 432+ $s .= "var skin = '" . Xml::escapeJsString( $this->getSkinName() ) . "';\n";
 433+ $s .= "var stylepath = '" . Xml::escapeJsString( $wgStylePath ) . "';";
432434 $s .= "\n\n/* MediaWiki:Common.js */\n";
433435 $commonJs = wfMsgForContent('common.js');
434436 if ( !wfEmptyMsg ( 'common.js', $commonJs ) ) {
Index: trunk/phase3/RELEASE-NOTES
@@ -266,7 +266,10 @@
267267 * Fix CSS media declaration for "screen, projection"; was causing some
268268 validation issues
269269 * (bug 10495) $wgMemcachedDebug set twice in includes/DefaultSettings.php
 270+* (bug 10316) Prevent inconsistent cached skin settings in gen=js by setting
 271+ the intended skin directly in the URL.
270272
 273+
271274 == API changes since 1.10 ==
272275
273276 Full API documentation is available at http://www.mediawiki.org/wiki/API

Follow-up revisions

RevisionCommit summaryAuthorDate
r24096Merged revisions 23910-24094 via svnmerge from...david22:38, 14 July 2007

Status & tagging log