From 3fc92e0c28ed517d4b165d4b8959027ed886a833 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Thu, 5 Jan 2006 04:26:52 +0000 Subject: [PATCH] removed $wgParserCache, converted to a singleton --- includes/Article.php | 10 ++++++---- includes/OutputPage.php | 9 +++++---- includes/ParserCache.php | 12 ++++++++++++ includes/Setup.php | 1 - 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 6530045999..c84f1a0461 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -701,11 +701,12 @@ class Article { function view() { global $wgUser, $wgOut, $wgRequest, $wgOnlySysopsCanPatrol, $wgContLang; global $wgEnableParserCache, $wgStylePath, $wgUseRCPatrol, $wgParser; - global $wgParserCache, $wgUseTrackbacks; + global $wgUseTrackbacks; $sk = $wgUser->getSkin(); $fname = 'Article::view'; wfProfileIn( $fname ); + $parserCache =& ParserCache::singleton(); # Get variables from query string $oldid = $this->getOldID(); @@ -743,7 +744,7 @@ class Article { } if ( empty( $oldid ) && $this->checkTouched() ) { - $wgOut->setETag($wgParserCache->getETag($this, $wgUser)); + $wgOut->setETag($parserCache->getETag($this, $wgUser)); if( $wgOut->checkLastModified( $this->mTouched ) ){ wfProfileOut( $fname ); @@ -2100,7 +2101,7 @@ class Article { * @param string $text */ function editUpdates( $text, $summary, $minoredit, $timestamp_of_pagechange, $newid) { - global $wgDeferredUpdateList, $wgMessageCache, $wgUser, $wgParser, $wgParserCache; + global $wgDeferredUpdateList, $wgMessageCache, $wgUser, $wgParser; $fname = 'Article::editUpdates'; wfProfileIn( $fname ); @@ -2110,7 +2111,8 @@ class Article { $poutput = $wgParser->parse( $text, $this->mTitle, $options, true, true, $newid ); # Save it to the parser cache - $wgParserCache->save( $poutput, $this, $wgUser ); + $parserCache =& ParserCache::singleton(); + $parserCache->save( $poutput, $this, $wgUser ); # Update the links tables $u = new LinksUpdate( $this->mTitle, $poutput ); diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 45b28b694a..53f3f177b5 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -308,13 +308,14 @@ class OutputPage { * Saves the text into the parser cache if possible */ function addPrimaryWikiText( $text, $article, $cache = true ) { - global $wgParser, $wgParserCache, $wgUser; + global $wgParser, $wgUser; $parserOutput = $wgParser->parse( $text, $article->mTitle, $this->mParserOptions, true, true, $this->mRevisionId ); if ( $article && $parserOutput->getCacheTime() != -1 ) { - $wgParserCache->save( $parserOutput, $article, $wgUser ); + $parserCache =& ParserCache::singleton(); + $parserCache->save( $parserOutput, $article, $wgUser ); } $this->addParserOutput( $parserOutput ); @@ -348,8 +349,8 @@ class OutputPage { * @return bool */ function tryParserCache( $article, $user ) { - global $wgParserCache; - $parserOutput = $wgParserCache->get( $article, $user ); + $parserCache =& ParserCache::singleton(); + $parserOutput = $parserCache->get( $article, $user ); if ( $parserOutput !== false ) { $this->mLanguageLinks += $parserOutput->getLanguageLinks(); $this->addCategoryLinks( $parserOutput->getCategories() ); diff --git a/includes/ParserCache.php b/includes/ParserCache.php index 53f7212824..ecb5fd700f 100644 --- a/includes/ParserCache.php +++ b/includes/ParserCache.php @@ -10,6 +10,18 @@ * @package MediaWiki */ class ParserCache { + /** + * Get an instance of this object + */ + function &singleton() { + static $instance; + if ( !isset( $instance ) ) { + global $parserMemc; + $instance = new ParserCache( $parserMemc ); + } + return $instance; + } + /** * Setup a cache pathway with a given back-end storage mechanism. * May be a memcached client or a BagOStuff derivative. diff --git a/includes/Setup.php b/includes/Setup.php index 5ea7ef9d27..ce94c3e061 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -281,7 +281,6 @@ $wgPostCommitUpdateList = array(); $wgMagicWords = array(); $wgMwRedir =& MagicWord::get( MAG_REDIRECT ); -$wgParserCache = new ParserCache( $messageMemc ); if ( $wgUseXMLparser ) { require_once( 'ParserXML.php' ); -- 2.20.1