Fixed efficiency problem with $wgSiteNotice. Introduced wfSiteNotice(), which allows the script to load it on demand instead of on every invocation
This commit is contained in:
parent
f21b45c57e
commit
ba9ae79212
7 changed files with 50 additions and 37 deletions
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 == '<sitenotice>') $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;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -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 == '<sitenotice>') $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' );
|
||||
|
||||
|
|
|
|||
|
|
@ -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() ;
|
||||
|
|
|
|||
|
|
@ -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 ;
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue