From: Domas Mituzas Date: Thu, 29 Dec 2005 22:03:54 +0000 (+0000) Subject: dirty sitenotice cache, will cache rendered sitenotice for 10 minutes, unless it... X-Git-Tag: 1.6.0~851 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=d014919229a3d56efd56344a64f5ec8fc59a9cd8;p=lhc%2Fweb%2Fwiklou.git dirty sitenotice cache, will cache rendered sitenotice for 10 minutes, unless it's wikitext changes does not deal with template or links changes... --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index fc1c0cb32f..60f56eae62 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1303,10 +1303,12 @@ function swap( &$x, &$y ) { } function wfGetSiteNotice() { - global $wgSiteNotice, $wgTitle, $wgOut; + global $wgSiteNotice, $wgTitle, $wgOut, $parserMemc, $wgDBname; $fname = 'wfGetSiteNotice'; wfProfileIn( $fname ); + $shouldParse=false; + $notice = wfMsgForContent( 'sitenotice' ); if( $notice == '<sitenotice>' || $notice == '-' ) { $notice = ''; @@ -1317,11 +1319,26 @@ function wfGetSiteNotice() { $notice = $wgSiteNotice; } if($notice != '-' && $notice != '') { - if( is_object( $wgOut ) ) { - $notice = $wgOut->parse( $notice ); + $cachednotice=$parserMemc->get("{$wgDBname}:sitenotice"); + if (is_array($cachednotice)) { + if (md5($notice)==$cachednotice['hash']) { + $notice = $cachednotice['html']; + } else { + $shouldParse=true; + } } else { - wfDebug( "wfGetSiteNotice called with no \$wgOut available" ); - $notice = ''; + $shouldParse=true; + } + if ($shouldParse) { + if( is_object( $wgOut ) ) { + $parsed = $wgOut->parse( $notice ); + $parserMemc->set("{$wgDBname}:sitenotice", + array('html' => $parsed, 'hash' => md5($notice)), 600); + $notice = $parsed; + } else { + wfDebug( "wfGetSiteNotice called with no \$wgOut available" ); + $notice = ''; + } } } wfProfileOut( $fname );