* (bug 10316) Prevent inconsistent cached skin settings in gen=js by setting the...
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 9 Jul 2007 21:39:42 +0000 (21:39 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 9 Jul 2007 21:39:42 +0000 (21:39 +0000)
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
includes/Skin.php
includes/SkinTemplate.php

index aaa25fc..2ecc411 100644 (file)
@@ -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 ==
 
index ae3b10d..aa56237 100644 (file)
@@ -354,11 +354,12 @@ class Skin extends Linker {
                $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n";
                global $wgUseSiteJs;
                if ($wgUseSiteJs) {
-                       if ($wgUser->isLoggedIn()) {
-                               $r .= "<script type=\"$wgJsMimeType\" src=\"".htmlspecialchars(self::makeUrl('-','action=raw&smaxage=0&gen=js'))."\"><!-- site js --></script>\n";
-                       } else {
-                               $r .= "<script type=\"$wgJsMimeType\" src=\"".htmlspecialchars(self::makeUrl('-','action=raw&gen=js'))."\"><!-- site js --></script>\n";
-                       }
+                       $jsCache = $wgUser->isLoggedIn() ? '&smaxage=0' : '';
+                       $r .= "<script type=\"$wgJsMimeType\" src=\"".
+                               htmlspecialchars(self::makeUrl('-',
+                                       "action=raw$jsCache&gen=js&useskin=" .
+                                       urlencode( $this->getSkinName() ) ) ) .
+                               "\"><!-- site js --></script>\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 ) ) {
index aebc68d..fcee523 100644 (file)
@@ -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);
                }