From d014919229a3d56efd56344a64f5ec8fc59a9cd8 Mon Sep 17 00:00:00 2001 From: Domas Mituzas Date: Thu, 29 Dec 2005 22:03:54 +0000 Subject: [PATCH] dirty sitenotice cache, will cache rendered sitenotice for 10 minutes, unless it's wikitext changes does not deal with template or links changes... --- includes/GlobalFunctions.php | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) 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 ); -- 2.20.1