Merge "ParserCache: Don't try to save to nothing if disabled"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 3 May 2016 01:59:57 +0000 (01:59 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 3 May 2016 01:59:57 +0000 (01:59 +0000)
1  2 
includes/parser/ParserCache.php

@@@ -146,17 -146,14 +146,17 @@@ class ParserCache 
                        if ( !$useOutdated && $optionsKey->expired( $article->getTouched() ) ) {
                                wfIncrStats( "pcache.miss.expired" );
                                $cacheTime = $optionsKey->getCacheTime();
 -                              wfDebug( "Parser options key expired, touched " . $article->getTouched()
 +                              wfDebugLog( "ParserCache",
 +                                      "Parser options key expired, touched " . $article->getTouched()
                                        . ", epoch $wgCacheEpoch, cached $cacheTime\n" );
                                return false;
 -                      } elseif ( $optionsKey->isDifferentRevision( $article->getLatest() ) ) {
 +                      } elseif ( !$useOutdated && $optionsKey->isDifferentRevision( $article->getLatest() ) ) {
                                wfIncrStats( "pcache.miss.revid" );
                                $revId = $article->getLatest();
                                $cachedRevId = $optionsKey->getCacheRevisionId();
 -                              wfDebug( "ParserOutput key is for an old revision, latest $revId, cached $cachedRevId\n" );
 +                              wfDebugLog( "ParserCache",
 +                                      "ParserOutput key is for an old revision, latest $revId, cached $cachedRevId\n"
 +                              );
                                return false;
                        }
  
                }
  
                $casToken = null;
 +              /** @var ParserOutput $value */
                $value = $this->mMemc->get( $parserOutputKey, $casToken, BagOStuff::READ_VERIFIED );
                if ( !$value ) {
                        wfDebug( "ParserOutput cache miss.\n" );
                if ( !$useOutdated && $value->expired( $touched ) ) {
                        wfIncrStats( "pcache.miss.expired" );
                        $cacheTime = $value->getCacheTime();
 -                      wfDebug( "ParserOutput key expired, touched $touched, "
 +                      wfDebugLog( "ParserCache",
 +                              "ParserOutput key expired, touched $touched, "
                                . "epoch $wgCacheEpoch, cached $cacheTime\n" );
                        $value = false;
 -              } elseif ( $value->isDifferentRevision( $article->getLatest() ) ) {
 +              } elseif ( !$useOutdated && $value->isDifferentRevision( $article->getLatest() ) ) {
                        wfIncrStats( "pcache.miss.revid" );
                        $revId = $article->getLatest();
                        $cachedRevId = $value->getCacheRevisionId();
 -                      wfDebug(
 +                      wfDebugLog( "ParserCache",
                                "ParserOutput key is for an old revision, latest $revId, cached $cachedRevId\n"
                        );
                        $value = false;
                        Hooks::run( 'RejectParserCacheValue', [ $value, $wikiPage, $popts ] ) === false
                ) {
                        wfIncrStats( 'pcache.miss.rejected' );
 -                      wfDebug(
 +                      wfDebugLog( "ParserCache",
                                "ParserOutput key valid, but rejected by RejectParserCacheValue hook handler.\n"
                        );
                        $value = false;
         */
        public function save( $parserOutput, $page, $popts, $cacheTime = null, $revId = null ) {
                $expire = $parserOutput->getCacheExpiry();
-               if ( $expire > 0 ) {
+               if ( $expire > 0 && !$this->mMemc instanceof EmptyBagOStuff ) {
                        $cacheTime = $cacheTime ?: wfTimestampNow();
                        if ( !$revId ) {
                                $revision = $page->getRevision();
                                'ParserCacheSaveComplete',
                                [ $this, $parserOutput, $page->getTitle(), $popts, $revId ]
                        );
-               } else {
+               } elseif ( $expire <= 0 ) {
                        wfDebug( "Parser output was marked as uncacheable and has not been saved.\n" );
                }
        }