ParserCache: Don't try to save to nothing if disabled
authorKunal Mehta <legoktm@member.fsf.org>
Wed, 27 Apr 2016 00:45:52 +0000 (17:45 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Tue, 3 May 2016 01:24:17 +0000 (18:24 -0700)
If the ParserCache is disabled via $wgParserCacheType = CACHE_NONE,
don't bother trying to save anything because it won't do anything.

This also removes the misleading "Saved in parser cache" HTML comment
from the rendered output since it isn't being saved at all.

Change-Id: I5603d2b2866f0079cdcd837b1f1a4efc00bc8ed9

includes/parser/ParserCache.php

index 916cfc2..f77a30f 100644 (file)
@@ -257,7 +257,7 @@ class ParserCache {
         */
        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();
@@ -297,7 +297,7 @@ class ParserCache {
                                'ParserCacheSaveComplete',
                                [ $this, $parserOutput, $page->getTitle(), $popts, $revId ]
                        );
-               } else {
+               } elseif ( $expire <= 0 ) {
                        wfDebug( "Parser output was marked as uncacheable and has not been saved.\n" );
                }
        }