From 33db268866a7feec8e9f7b053105d98a7b5bc79c Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 9 Jul 2007 21:39:42 +0000 Subject: [PATCH] * (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. --- RELEASE-NOTES | 3 +++ includes/Skin.php | 14 ++++++++------ includes/SkinTemplate.php | 10 +++++----- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index aaa25fc2ab..2ecc411a2d 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -266,6 +266,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Fix CSS media declaration for "screen, projection"; was causing some validation issues * (bug 10495) $wgMemcachedDebug set twice in includes/DefaultSettings.php +* (bug 10316) Prevent inconsistent cached skin settings in gen=js by setting + the intended skin directly in the URL. + == API changes since 1.10 == diff --git a/includes/Skin.php b/includes/Skin.php index ae3b10d8a1..aa5623773a 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -354,11 +354,12 @@ class Skin extends Linker { $r .= "\n"; global $wgUseSiteJs; if ($wgUseSiteJs) { - if ($wgUser->isLoggedIn()) { - $r .= "\n"; - } else { - $r .= "\n"; - } + $jsCache = $wgUser->isLoggedIn() ? '&smaxage=0' : ''; + $r .= "\n"; } if( $allowUserJs && $wgUser->isLoggedIn() ) { $userpage = $wgUser->getUserPage(); @@ -427,7 +428,8 @@ class Skin extends Linker { global $wgStylePath; $s = "/* generated javascript */\n"; - $s .= "var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';"; + $s .= "var skin = '" . Xml::escapeJsString( $this->getSkinName() ) . "';\n"; + $s .= "var stylepath = '" . Xml::escapeJsString( $wgStylePath ) . "';"; $s .= "\n\n/* MediaWiki:Common.js */\n"; $commonJs = wfMsgForContent('common.js'); if ( !wfEmptyMsg ( 'common.js', $commonJs ) ) { diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index aebc68d5f9..fcee523563 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -285,11 +285,11 @@ class SkinTemplate extends Skin { $tpl->setRef( 'userjsprev', $this->userjsprev); global $wgUseSiteJs; if ($wgUseSiteJs) { - if($this->loggedin) { - $tpl->set( 'jsvarurl', self::makeUrl('-','action=raw&smaxage=0&gen=js') ); - } else { - $tpl->set( 'jsvarurl', self::makeUrl('-','action=raw&gen=js') ); - } + $jsCache = $this->loggedin ? '&smaxage=0' : ''; + $tpl->set( 'jsvarurl', + self::makeUrl('-', + "action=raw$jsCache&gen=js&useskin=" . + urlencode( $this->getSkinName() ) ) ); } else { $tpl->set('jsvarurl', false); } -- 2.20.1