* Added global $wgStyleVersion to centralize bumping CSS and JS file versions
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 13 Oct 2006 21:48:19 +0000 (21:48 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 13 Oct 2006 21:48:19 +0000 (21:48 +0000)
  for cache-friendly style and script updating

13 files changed:
RELEASE-NOTES
includes/DefaultSettings.php
includes/EditPage.php
includes/Feed.php
includes/ImagePage.php
includes/OutputPage.php
includes/ProtectionForm.php
includes/Skin.php
includes/SkinTemplate.php
skins/CologneBlue.php
skins/MonoBook.php
skins/Nostalgia.php
skins/Standard.php

index d35be10..dcfb25c 100644 (file)
@@ -44,6 +44,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 6868) Un-hardcode section edit link style
 * (bug 3205) Stop right floats from stacking horizontally in non-Monobook skins
 * (bug 2013) Inherit ratios and not computed values for line-height
+* Added global $wgStyleVersion to centralize bumping CSS and JS file versions
+  for cache-friendly style and script updating
+
 
 == Languages updated ==
 
index 6e35b71..b74751a 100644 (file)
@@ -1024,6 +1024,13 @@ $wgCachePages       = true;
  */
 $wgCacheEpoch = '20030516000000';
 
+/**
+ * Bump this number when changing the global style sheets and JavaScript.
+ * It should be appended in the query string of static CSS and JS includes,
+ * to ensure that client-side caches don't keep obsolete copies of global
+ * styles.
+ */
+$wgStyleVersion = '11';
 
 # Server-side caching:
 
index a1207d1..ce224e5 100644 (file)
@@ -1290,9 +1290,9 @@ END
         * of the preview button
         */
        function doLivePreviewScript() {
-               global $wgStylePath, $wgJsMimeType, $wgOut, $wgTitle;
+               global $wgStylePath, $wgJsMimeType, $wgStyleVersion, $wgOut, $wgTitle;
                $wgOut->addHTML( '<script type="'.$wgJsMimeType.'" src="' .
-                       htmlspecialchars( $wgStylePath . '/common/preview.js' ) .
+                       htmlspecialchars( "$wgStylePath/common/preview.js?$wgStyleVersion" ) .
                        '"></script>' . "\n" );
                $liveAction = $wgTitle->getLocalUrl( 'action=submit&wpPreview=true&live=true' );
                return "return !livePreview(" .
index 7663e82..5c14865 100644 (file)
@@ -149,12 +149,12 @@ class ChannelFeed extends FeedItem {
         * @private
         */
        function outXmlHeader() {
-               global $wgServer, $wgStylePath;
+               global $wgServer, $wgStylePath, $wgStyleVersion;
 
                $this->httpHeaders();
                echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
                echo '<?xml-stylesheet type="text/css" href="' .
-                       htmlspecialchars( "$wgServer$wgStylePath/common/feed.css" ) . '"?' . ">\n";
+                       htmlspecialchars( "$wgServer$wgStylePath/common/feed.css?$wgStyleVersion" ) . '"?' . ">\n";
        }
 }
 
index 908dd5c..02c4c2e 100644 (file)
@@ -71,13 +71,13 @@ class ImagePage extends Article {
                        $this->imageHistory();
                        $this->imageLinks();
                        if( $exif ) {
-                               global $wgStylePath;
+                               global $wgStylePath, $wgStyleVersion;
                                $expand = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-expand' ) ) );
                                $collapse = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-collapse' ) ) );
                                $wgOut->addHTML( "<h2 id=\"metadata\">" . wfMsgHtml( 'metadata' ) . "</h2>\n" );
                                $wgOut->addWikiText( $this->makeMetadataTable( $exif ) );
                                $wgOut->addHTML(
-                                       "<script type=\"text/javascript\" src=\"$wgStylePath/common/metadata.js\"></script>\n" .
+                                       "<script type=\"text/javascript\" src=\"$wgStylePath/common/metadata.js?wgStyleVersion\"></script>\n" .
                                        "<script type=\"text/javascript\">attachMetadataToggle('mw_metadata', '$expand', '$collapse');</script>\n" );
                        }
                } else {
index 0d55c2e..f560397 100644 (file)
@@ -481,6 +481,7 @@ class OutputPage {
                global $wgUser, $wgOutputEncoding, $wgRequest;
                global $wgContLanguageCode, $wgDebugRedirects, $wgMimeType;
                global $wgJsMimeType, $wgStylePath, $wgUseAjax, $wgAjaxSearch, $wgScriptPath, $wgServer;
+               global $wgStyleVersion;
 
                if( $this->mDoNothing ){
                        return;
@@ -490,11 +491,11 @@ class OutputPage {
                $sk = $wgUser->getSkin();
 
                if ( $wgUseAjax ) {
-                       $this->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajax.js\"></script>\n" );
+                       $this->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajax.js?$wgStyleVersion\"></script>\n" );
                }
 
                if ( $wgUseAjax && $wgAjaxSearch ) {
-                       $this->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajaxsearch.js\"></script>\n" );
+                       $this->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajaxsearch.js?$wgStyleVersion\"></script>\n" );
                        $this->addScript( "<script type=\"{$wgJsMimeType}\">hookEvent(\"load\", sajax_onload);</script>\n" );
                }
 
@@ -969,7 +970,7 @@ class OutputPage {
         */
        function headElement() {
                global $wgDocType, $wgDTD, $wgContLanguageCode, $wgOutputEncoding, $wgMimeType;
-               global $wgUser, $wgContLang, $wgUseTrackbacks, $wgTitle;
+               global $wgUser, $wgContLang, $wgUseTrackbacks, $wgTitle, $wgStyleVersion;
 
                if( $wgMimeType == 'text/xml' || $wgMimeType == 'application/xhtml+xml' || $wgMimeType == 'application/xml' ) {
                        $ret = "<?xml version=\"1.0\" encoding=\"$wgOutputEncoding\" ?>\n";
@@ -995,7 +996,7 @@ class OutputPage {
                } else {
                        $media = "media='print'";
                }
-               $printsheet = htmlspecialchars( "$wgStylePath/common/wikiprintable.css" );
+               $printsheet = htmlspecialchars( "$wgStylePath/common/wikiprintable.css?$wgStyleVersion" );
                $ret .= "<link rel='stylesheet' type='text/css' $media href='$printsheet' />\n";
 
                $sk = $wgUser->getSkin();
index fd1bc81..f96262f 100644 (file)
@@ -212,9 +212,9 @@ class ProtectionForm {
        }
 
        function buildScript() {
-               global $wgStylePath;
+               global $wgStylePath, $wgStyleVersion;
                return '<script type="text/javascript" src="' .
-                       htmlspecialchars( $wgStylePath . "/common/protect.js" ) .
+                       htmlspecialchars( $wgStylePath . "/common/protect.js?$wgStyleVersion" ) .
                        '"></script>';
        }
 
index 3cd3913..6baad7e 100644 (file)
@@ -139,7 +139,7 @@ class Skin extends Linker {
 
        /** @return string path to the skin stylesheet */
        function getStylesheet() {
-               return 'common/wikistandard.css?2';
+               return 'common/wikistandard.css';
        }
 
        /** @return string skin name */
@@ -296,7 +296,7 @@ class Skin extends Linker {
        }
 
        function getHeadScripts() {
-               global $wgStylePath, $wgUser, $wgAllowUserJs, $wgJsMimeType;
+               global $wgStylePath, $wgUser, $wgAllowUserJs, $wgJsMimeType, $wgStyleVersion;
                global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
                global $wgTitle, $wgCanonicalNamespaceNames, $wgOut;
 
@@ -323,7 +323,7 @@ class Skin extends Linker {
 
                $r = self::makeGlobalVariablesScript( $vars );
 
-               $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
+               $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n";
                if( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
                        $userpage = $wgUser->getUserPage();
                        $userjs = htmlspecialchars( self::makeUrl(
@@ -360,10 +360,10 @@ class Skin extends Linker {
 
        # get the user/site-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way)
        function getUserStylesheet() {
-               global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage;
+               global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage, $wgStyleVersion;
                $sheet = $this->getStylesheet();
                $action = $wgRequest->getText('action');
-               $s = "@import \"$wgStylePath/$sheet\";\n";
+               $s = "@import \"$wgStylePath/$sheet?$wgStyleVersion\";\n";
                if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css?1\";\n";
 
                $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
index 9a94821..4ae54d9 100644 (file)
@@ -932,7 +932,10 @@ class SkinTemplate extends Skin {
                        $siteargs .= '&ts=' . $wgUser->mTouched;
                }
 
-               if ($wgContLang->isRTL()) $sitecss .= '@import "' . $wgStylePath . '/' . $this->stylename . '/rtl.css?1";' . "\n";
+               if( $wgContLang->isRTL() ) {
+                       global $wgStyleVersion;
+                       $sitecss .= "@import \"$wgStylePath/$this->stylename/rtl.css?$wgStyleVersion\";\n";
+               }
 
                # If we use the site's dynamic CSS, throw that in, too
                if ( $wgUseSiteCss ) {
index 8cc8a92..5612706 100644 (file)
@@ -18,7 +18,7 @@ if( !defined( 'MEDIAWIKI' ) )
 class SkinCologneBlue extends Skin {
 
        function getStylesheet() {
-               return "common/cologneblue.css?4";
+               return 'common/cologneblue.css';
        }
        function getSkinName() {
                return "cologneblue";
index 92c88c9..299e5d4 100644 (file)
@@ -56,18 +56,18 @@ class MonoBookTemplate extends QuickTemplate {
                <meta http-equiv="Content-Type" content="<?php $this->text('mimetype') ?>; charset=<?php $this->text('charset') ?>" />
                <?php $this->html('headlinks') ?>
                <title><?php $this->text('pagetitle') ?></title>
-               <style type="text/css" media="screen,projection">/*<![CDATA[*/ @import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/main.css?10"; /*]]>*/</style>
-               <link rel="stylesheet" type="text/css" <?php if(empty($this->data['printable']) ) { ?>media="print"<?php } ?> href="<?php $this->text('stylepath') ?>/common/commonPrint.css?1" />
-               <!--[if lt IE 5.5000]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE50Fixes.css";</style><![endif]-->
-               <!--[if IE 5.5000]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE55Fixes.css";</style><![endif]-->
-               <!--[if IE 6]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE60Fixes.css";</style><![endif]-->
-               <!--[if IE 7]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE70Fixes.css?1";</style><![endif]-->
-               <!--[if lt IE 7]><script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath') ?>/common/IEFixes.js"></script>
+               <style type="text/css" media="screen,projection">/*<![CDATA[*/ @import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/main.css?<?php echo $GLOBALS['wgStyleVersion'] ?>"; /*]]>*/</style>
+               <link rel="stylesheet" type="text/css" <?php if(empty($this->data['printable']) ) { ?>media="print"<?php } ?> href="<?php $this->text('stylepath') ?>/common/commonPrint.css?<?php echo $GLOBALS['wgStyleVersion'] ?>" />
+               <!--[if lt IE 5.5000]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE50Fixes.css?<?php echo $GLOBALS['wgStyleVersion'] ?>";</style><![endif]-->
+               <!--[if IE 5.5000]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE55Fixes.css?<?php echo $GLOBALS['wgStyleVersion'] ?>";</style><![endif]-->
+               <!--[if IE 6]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE60Fixes.css?<?php echo $GLOBALS['wgStyleVersion'] ?>";</style><![endif]-->
+               <!--[if IE 7]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE70Fixes.css?<?php echo $GLOBALS['wgStyleVersion'] ?>";</style><![endif]-->
+               <!--[if lt IE 7]><script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath') ?>/common/IEFixes.js?<?php echo $GLOBALS['wgStyleVersion'] ?>"></script>
                <meta http-equiv="imagetoolbar" content="no" /><![endif]-->
                
                <?php print Skin::makeGlobalVariablesScript( $this->data ); ?>
                 
-               <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath' ) ?>/common/wikibits.js?2"><!-- wikibits js --></script>
+               <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath' ) ?>/common/wikibits.js?<?php echo $GLOBALS['wgStyleVersion'] ?>"><!-- wikibits js --></script>
 <?php  if($this->data['jsvarurl'  ]) { ?>
                <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('jsvarurl'  ) ?>"><!-- site js --></script>
 <?php  } ?>
index 214c70d..0d67599 100644 (file)
@@ -18,7 +18,7 @@ if( !defined( 'MEDIAWIKI' ) )
 class SkinNostalgia extends Skin {
 
        function getStylesheet() {
-               return 'common/nostalgia.css?2';
+               return 'common/nostalgia.css';
        }
        function getSkinName() {
                return "nostalgia";
index 90bcfc5..517fd19 100644 (file)
@@ -21,12 +21,12 @@ class SkinStandard extends Skin {
         *
         */
        function getHeadScripts() {
-               global $wgStylePath, $wgJsMimeType;
+               global $wgStylePath, $wgJsMimeType, $wgStyleVersion;
 
                $s = parent::getHeadScripts();
                if ( 3 == $this->qbSetting() ) { # Floating left
                        $s .= "<script language='javascript' type='$wgJsMimeType' " .
-                         "src='{$wgStylePath}/common/sticky.js'></script>\n";
+                         "src='{$wgStylePath}/common/sticky.js?$wgStyleVersion'></script>\n";
                }
                return $s;
        }
@@ -35,14 +35,14 @@ class SkinStandard extends Skin {
         *
         */
        function getUserStyles() {
-               global $wgStylePath;
+               global $wgStylePath, $wgStyleVersion;
                $s = '';
                if ( 3 == $this->qbSetting() ) { # Floating left
                        $s .= "<style type='text/css'>\n" .
-                         "@import '{$wgStylePath}/common/quickbar.css';\n</style>\n";
+                         "@import '{$wgStylePath}/common/quickbar.css?$wgStyleVersion';\n</style>\n";
                } else if ( 4 == $this->qbSetting() ) { # Floating right
                        $s .= "<style type='text/css'>\n" .
-                         "@import '{$wgStylePath}/common/quickbar-right.css';\n</style>\n";
+                         "@import '{$wgStylePath}/common/quickbar-right.css?$wgStyleVersion';\n</style>\n";
                }
                $s .= parent::getUserStyles();
                return $s;