Removed trailing whitespace from ParserCache.php
[lhc/web/wiklou.git] / includes / parser / ParserCache.php
index 0faa40a..dae0c68 100644 (file)
@@ -27,8 +27,6 @@
  */
 class ParserCache {
        private $mMemc;
-       const try116cache = false; /* Only useful $wgParserCacheExpireTime after updating to 1.17 */
-
        /**
         * Get an instance of this object
         *
@@ -67,7 +65,7 @@ class ParserCache {
 
                // idhash seem to mean 'page id' + 'rendering hash' (r3710)
                $pageid = $article->getID();
-               $renderkey = (int)($wgRequest->getVal( 'action' ) == 'render');
+               $renderkey = (int)( $wgRequest->getVal( 'action' ) == 'render' );
 
                $key = wfMemcKey( 'pcache', 'idhash', "{$pageid}-{$renderkey}!{$hash}" );
                return $key;
@@ -128,7 +126,7 @@ class ParserCache {
        public function getKey( $article, $popts, $useOutdated = true ) {
                global $wgCacheEpoch;
 
-               if( $popts instanceof User ) {
+               if ( $popts instanceof User ) {
                        wfWarn( "Use of outdated prototype ParserCache::getKey( &\$article, &\$user )\n" );
                        $popts = ParserOptions::newFromUser( $popts );
                }
@@ -146,7 +144,7 @@ class ParserCache {
                        $usedOptions = $optionsKey->mUsedOptions;
                        wfDebug( "Parser cache options found.\n" );
                } else {
-                       if ( !$useOutdated && !self::try116cache ) {
+                       if ( !$useOutdated ) {
                                return false;
                        }
                        $usedOptions = ParserOptions::legacyOptions();
@@ -186,12 +184,6 @@ class ParserCache {
                }
 
                $value = $this->mMemc->get( $parserOutputKey );
-               if ( self::try116cache && !$value && strpos( $value, '*' ) !== -1 ) {
-                       wfDebug( "New format parser cache miss.\n" );
-                       $parserOutputKey = $this->getParserOutputKey( $article,
-                               $popts->optionsHash( ParserOptions::legacyOptions(), $article->getTitle() ) );
-                       $value = $this->mMemc->get( $parserOutputKey );
-               }
                if ( !$value ) {
                        wfDebug( "ParserOutput cache miss.\n" );
                        wfIncrStats( "pcache_miss_absent" );
@@ -220,22 +212,22 @@ class ParserCache {
        }
 
        /**
-        * @param $parserOutput ParserOutput
-        * @param $article Article
-        * @param $popts ParserOptions
+        * @param ParserOutput $parserOutput
+        * @param Article $article
+        * @param ParserOptions $popts
+        * @param string $cacheTime Time when the cache was generated
         */
-       public function save( $parserOutput, $article, $popts ) {
+       public function save( $parserOutput, $article, $popts, $cacheTime = null ) {
                $expire = $parserOutput->getCacheExpiry();
-
-               if( $expire > 0 ) {
-                       $now = wfTimestampNow();
+               if ( $expire > 0 ) {
+                       $cacheTime = $cacheTime ?: wfTimestampNow();
 
                        $optionsKey = new CacheTime;
                        $optionsKey->mUsedOptions = $parserOutput->getUsedOptions();
                        $optionsKey->updateCacheExpiry( $expire );
 
-                       $optionsKey->setCacheTime( $now );
-                       $parserOutput->setCacheTime( $now );
+                       $optionsKey->setCacheTime( $cacheTime );
+                       $parserOutput->setCacheTime( $cacheTime );
 
                        $optionsKey->setContainsOldMagic( $parserOutput->containsOldMagic() );
 
@@ -245,8 +237,8 @@ class ParserCache {
                        // Save the timestamp so that we don't have to load the revision row on view
                        $parserOutput->setTimestamp( $article->getTimestamp() );
 
-                       $parserOutput->mText .= "\n<!-- Saved in parser cache with key $parserOutputKey and timestamp $now -->\n";
-                       wfDebug( "Saved in parser cache with key $parserOutputKey and timestamp $now\n" );
+                       $parserOutput->mText .= "\n<!-- Saved in parser cache with key $parserOutputKey and timestamp $cacheTime\n -->\n";
+                       wfDebug( "Saved in parser cache with key $parserOutputKey and timestamp $cacheTime\n" );
 
                        // Save the parser output
                        $this->mMemc->set( $parserOutputKey, $parserOutput, $expire );