Add vary-revision-exist flag to handle {{REVISIONID}} and parser cache
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 12 Apr 2019 23:54:31 +0000 (16:54 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Sat, 13 Apr 2019 00:20:50 +0000 (17:20 -0700)
Follow-up to c537eb186862b3

Bug: T220854
Change-Id: Idc19cc29764a38e3671ca1dea158bd5fb46eaf4d

includes/Revision/RenderedRevision.php
includes/parser/Parser.php

index 094105a..d3e5938 100644 (file)
@@ -395,6 +395,14 @@ class RenderedRevision implements SlotRenderingProvider {
                                "$method: Prepared output has vary-revision-id with wrong ID...\n"
                        );
                        return true;
+               } elseif ( $out->getFlag( 'vary-revision-exists' ) ) {
+                       // If {{REVISIONID}} resolved to '', it now needs to resolve to '-'.
+                       // Note that edit stashing always uses '-', which can be used for both
+                       // edit filter checks and canonical parser cache.
+                       $this->saveParseLogger->info(
+                               "$method: Prepared output has vary-revision-exists...\n"
+                       );
+                       return true;
                } else {
                        // NOTE: In the original fix for T135261, the output was discarded if 'vary-user' was
                        // set for a null-edit. The reason was that the original rendering in that case was
index 9ff731d..91de550 100644 (file)
@@ -2607,7 +2607,13 @@ class Parser {
                        // @TODO: disallow this word on all namespaces
                        $this->nsInfo->isContent( $this->mTitle->getNamespace() )
                ) {
-                       return $this->mRevisionId ? '-' : '';
+                       if ( $this->mRevisionId ) {
+                               return '-';
+                       } else {
+                               $this->mOutput->setFlag( 'vary-revision-exists' );
+
+                               return '';
+                       }
                };
 
                $pageLang = $this->getFunctionLang();