Fixed efficiency problem with $wgSiteNotice. Introduced wfSiteNotice(), which allows...
authorTim Starling <tstarling@users.mediawiki.org>
Sun, 27 Mar 2005 16:56:11 +0000 (16:56 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sun, 27 Mar 2005 16:56:11 +0000 (16:56 +0000)
includes/Database.php
includes/GlobalFunctions.php
includes/Setup.php
includes/Skin.php
includes/SkinTemplate.php
skins/CologneBlue.php
skins/Nostalgia.php

index a43f5b0..9eb8ab3 100644 (file)
@@ -1459,7 +1459,7 @@ class ResultWrapper {
  * Displays the file cache if possible
  */
 function wfEmergencyAbort( &$conn, $error ) {
-       global $wgTitle, $wgUseFileCache, $title, $wgInputEncoding, $wgSiteNotice, $wgOutputEncoding;
+       global $wgTitle, $wgUseFileCache, $title, $wgInputEncoding, $wgOutputEncoding;
        global $wgSitename, $wgServer;
        
        # I give up, Brion is right. Getting the message cache to work when there is no DB is tricky.
@@ -1502,7 +1502,7 @@ border=\"0\" ALT=\"Google\"></A>
                header( 'Cache-control: none' );
                header( 'Pragma: nocache' );
        }
-       $msg = $wgSiteNotice;
+       $msg = wfGetSiteNotice();
        if($msg == '') {
                $msg = str_replace( '$1', $error, $noconnect );
        }
index ea209c9..c758cc8 100644 (file)
@@ -1051,4 +1051,37 @@ function wfIsWindows() {
        }   
 } 
 
+/**
+ * Swap two variables
+ */
+function swap( &$x, &$y ) {
+       $z = $x;
+       $x = $y;
+       $y = $z;
+}
+
+function wfGetSiteNotice() {
+       global $wgSiteNotice;
+       $fname = 'wfGetSiteNotice';
+       wfProfileIn( $fname );
+
+       $notice = wfMsg( 'sitenotice' );
+       if($notice == '&lt;sitenotice&gt;') $notice = '';
+       # Allow individual wikis to turn it off
+       if ( $notice == '-' ) {
+               $notice = '';
+       } else {
+               if ($notice == '') {
+                       $notice = $wgSiteNotice;
+               }
+               if($notice != '-' && $notice != '') {
+                       $specialparser = new Parser();
+                       $parserOutput = $specialparser->parse( $notice, $wgTitle, $wgOut->mParserOptions, false );
+                       $notice = $parserOutput->getText();
+               }
+       }
+       wfProfileOut( $fname );
+       return $notice;
+}
+
 ?>
index a43cfc3..c615667 100644 (file)
@@ -384,29 +384,6 @@ wfSeedRandom();
 $wgTitle = Title::makeTitle( NS_SPECIAL, 'Error' );
 $wgArticle = new Article($wgTitle);
 
-# Site notice
-# FIXME: This is an ugly hack, which wastes runtime on cache hits
-# and raw page views by forcing initialization of the message cache.
-# Try to fake around it for raw at least:
-if( !isset( $_REQUEST['action'] ) || $_REQUEST['action'] != 'raw' ) {
-       $notice = wfMsg( 'sitenotice' );
-       if($notice == '&lt;sitenotice&gt;') $notice = '';
-       # Allow individual wikis to turn it off
-       if ( $notice == '-' ) {
-               $wgSiteNotice = '';
-       } else {
-               # if($wgSiteNotice) $notice .= $wgSiteNotice;
-               if ($notice == '') {
-                       $notice = $wgSiteNotice;
-               }
-               if($notice != '-' && $notice != '') {
-                       $specialparser = new Parser();
-                       $parserOutput = $specialparser->parse( $notice, $wgTitle, $wgOut->mParserOptions, false );
-                       $wgSiteNotice = $parserOutput->getText();
-               }
-       }
-}
-
 wfProfileOut( $fname.'-misc2' );
 wfProfileIn( $fname.'-extensions' );
 
index de7777d..daf3ba4 100644 (file)
@@ -356,7 +356,7 @@ END;
        }
 
        function doBeforeContent() {
-               global $wgOut, $wgTitle, $wgContLang, $wgSiteNotice;
+               global $wgOut, $wgTitle, $wgContLang;
                $fname = 'Skin::doBeforeContent';
                wfProfileIn( $fname );
 
@@ -406,8 +406,9 @@ END;
                $s .= "</tr>\n</table>\n</div>\n";
                $s .= "\n<div id='article'>\n";
 
-               if( $wgSiteNotice ) {
-                       $s .= "\n<div id='siteNotice'>$wgSiteNotice</div>\n";
+               $notice = wfGetSiteNotice();
+               if( $notice ) {
+                       $s .= "\n<div id='siteNotice'>$notice</div>\n";
                }
                $s .= $this->pageTitle();
                $s .= $this->pageSubtitle() ;
index 84ada02..87c8135 100644 (file)
@@ -146,7 +146,7 @@ class SkinTemplate extends Skin {
                global $wgTitle, $wgArticle, $wgUser, $wgLang, $wgContLang, $wgOut;
                global $wgScript, $wgStylePath, $wgLanguageCode, $wgContLanguageCode, $wgUseNewInterlanguage;
                global $wgMimeType, $wgOutputEncoding, $wgUseDatabaseMessages, $wgRequest;
-               global $wgDisableCounters, $wgLogo, $action, $wgFeedClasses, $wgSiteNotice;
+               global $wgDisableCounters, $wgLogo, $action, $wgFeedClasses;
                global $wgMaxCredits, $wgShowCreditsIfMax;
                global $wgPageShowWatchingUsers;
 
@@ -344,8 +344,7 @@ class SkinTemplate extends Skin {
 
                $tpl->setRef( 'debug', $out->mDebugtext );
                $tpl->set( 'reporttime', $out->reportTime() );
-               $tpl->set( 'sitenotice', $wgSiteNotice );
-               $tpl->set( 'tagline', wfMsg('tagline') );
+               $tpl->set( 'sitenotice', wfGetSiteNotice() );
 
                $printfooter = "<div class=\"printfooter\">\n" . $this->printSource() . "</div>\n";
                $out->mBodytext .= $printfooter ;
index 06e5d46..8571b4b 100644 (file)
@@ -25,7 +25,7 @@ class SkinCologneBlue extends Skin {
        }
 
        function doBeforeContent() {
-               global $wgOut, $wgTitle, $wgSiteNotice;
+               global $wgOut, $wgTitle;
 
                $s = "";
                $qb = $this->qbSetting();
@@ -57,8 +57,9 @@ class SkinCologneBlue extends Skin {
 
                $s .= "\n</div>\n<div id='article'>";
 
-               if( $wgSiteNotice ) {
-                       $s .= "\n<div id='siteNotice'>$wgSiteNotice</div>\n";
+               $notice = wfGetSiteNotice();
+               if( $notice ) {
+                       $s .= "\n<div id='siteNotice'>$notice</div>\n";
                }
                $s .= $this->pageTitle();
                $s .= $this->pageSubtitle() . "\n";
index 02b5d8b..4bf4bf6 100644 (file)
@@ -29,7 +29,7 @@ class SkinNostalgia extends Skin {
        }
 
        function doBeforeContent() {
-               global $wgUser, $wgOut, $wgTitle, $wgSiteNotice;
+               global $wgUser, $wgOut, $wgTitle;
 
                $s = "\n<div id='content'>\n<div id='topbar'>";
                $s .= $this->logoText( "right" );
@@ -38,8 +38,10 @@ class SkinNostalgia extends Skin {
                $s .= $this->pageSubtitle() . "\n";
 
                $s .= $this->topLinks() . "\n<br />";
-               if( $wgSiteNotice ) {
-                       $s .= "\n<div id='siteNotice'>$wgSiteNotice</div>\n";
+
+               $notice = wfGetSiteNotice();
+               if( $notice ) {
+                       $s .= "\n<div id='siteNotice'>$notice</div>\n";
                }
                $s .= $this->pageTitleLinks();