From 5e6d9340cb81d0040cbeb2371a83e884db90cd68 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Fri, 12 Apr 2019 16:54:31 -0700 Subject: [PATCH] Add vary-revision-exist flag to handle {{REVISIONID}} and parser cache Follow-up to c537eb186862b3 Bug: T220854 Change-Id: Idc19cc29764a38e3671ca1dea158bd5fb46eaf4d --- includes/Revision/RenderedRevision.php | 8 ++++++++ includes/parser/Parser.php | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/includes/Revision/RenderedRevision.php b/includes/Revision/RenderedRevision.php index 094105aae8..d3e5938c86 100644 --- a/includes/Revision/RenderedRevision.php +++ b/includes/Revision/RenderedRevision.php @@ -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 diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 9ff731d801..91de550fad 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -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(); -- 2.20.1