Fixed $wgCacheEpoch handling
authorTim Starling <tstarling@users.mediawiki.org>
Sun, 30 May 2004 07:31:26 +0000 (07:31 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sun, 30 May 2004 07:31:26 +0000 (07:31 +0000)
includes/Parser.php
includes/ParserCache.php

index 5da9c97..ebddd60 100644 (file)
@@ -2001,7 +2001,7 @@ class Parser
 class ParserOutput
 {
        var $mText, $mLanguageLinks, $mCategoryLinks, $mContainsOldMagic;
-       var $mTouched; # Used for caching
+       var $mCacheTime; # Used in ParserCache
 
        function ParserOutput( $text = "", $languageLinks = array(), $categoryLinks = array(),
                $containsOldMagic = false )
@@ -2010,19 +2010,19 @@ class ParserOutput
                $this->mLanguageLinks = $languageLinks;
                $this->mCategoryLinks = $categoryLinks;
                $this->mContainsOldMagic = $containsOldMagic;
-               $this->mTouched = "";
+               $this->mCacheTime = "";
        }
 
        function getText() { return $this->mText; }
        function getLanguageLinks() { return $this->mLanguageLinks; }
        function getCategoryLinks() { return $this->mCategoryLinks; }
-       function getTouched() { return $this->mTouched; }
+       function getCacheTime() { return $this->mCacheTime; }
        function containsOldMagic() { return $this->mContainsOldMagic; }
        function setText( $text ) { return wfSetVar( $this->mText, $text ); }
        function setLanguageLinks( $ll ) { return wfSetVar( $this->mLanguageLinks, $ll ); }
        function setCategoryLinks( $cl ) { return wfSetVar( $this->mCategoryLinks, $cl ); }
        function setContainsOldMagic( $com ) { return wfSetVar( $this->mContainsOldMagic, $com ); }
-       function setTouched( $t ) { return wfSetVar( $this->mTouched, $t ); }
+       function setCacheTime( $t ) { return wfSetVar( $this->mCacheTime, $t ); }
 
        function merge( $other ) {
                $this->mLanguageLinks = array_merge( $this->mLanguageLinks, $other->mLanguageLinks );
index 468fdc1..8066e4f 100644 (file)
@@ -22,7 +22,7 @@ class ParserCache
                if ( $value ) {
                        # Delete if article has changed since the cache was made
                        $touched = $article->getTouched();
-                       if ( $value->getTouched() != $touched || $touched > $wgCacheEpoch ) {
+                       if ( $value->getCacheTime() <= $touched || $value->getCacheTime < $wgCacheEpoch ) {
                                $wgMemc->delete( $key );
                                $value = false;
                        }
@@ -37,19 +37,18 @@ class ParserCache
        function save( $parserOutput, &$article, &$user ){
                global $wgMemc;
                $key = $this->getKey( $article, $user );
-               $touched = $article->getTouched();
-               $parserOutput->setTouched( $touched );
-               $parserOutput->mText .= "\n<!-- Saved in parser cache with key $key and timestamp $touched -->\n";
+               $now = wfTimestampNow();
+               $parserOutput->setCacheTime( $now );
+               $parserOutput->mText .= "\n<!-- Saved in parser cache with key $key and timestamp $now -->\n";
 
                if( $parserOutput->containsOldMagic() ){
                        $expire = 3600; # 1 hour
                } else {
-                       $expire = 7*86400; # 7 days
+                       $expire = 86400; # 1 day
                }
 
                $wgMemc->set( $key, $parserOutput, $expire );
        }
-       
 }