removed $wgParserCache, converted to a singleton
authorTim Starling <tstarling@users.mediawiki.org>
Thu, 5 Jan 2006 04:26:52 +0000 (04:26 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Thu, 5 Jan 2006 04:26:52 +0000 (04:26 +0000)
includes/Article.php
includes/OutputPage.php
includes/ParserCache.php
includes/Setup.php

index 6530045..c84f1a0 100644 (file)
@@ -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 );
index 45b28b6..53f3f17 100644 (file)
@@ -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() );
index 53f7212..ecb5fd7 100644 (file)
  * @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.
index 5ea7ef9..ce94c3e 100644 (file)
@@ -281,7 +281,6 @@ $wgPostCommitUpdateList = array();
 
 $wgMagicWords = array();
 $wgMwRedir =& MagicWord::get( MAG_REDIRECT );
-$wgParserCache = new ParserCache( $messageMemc );
 
 if ( $wgUseXMLparser ) {
        require_once( 'ParserXML.php' );