X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FRevision%2FRenderedRevision.php;h=3bc8dda57844e043921bd9935dcac55f297c134f;hb=91ec64c80719f002426ada7aa1ed62b465c66a0a;hp=4acb9c0a64549aca9f189e0737f596487eadadca;hpb=ed0193f1fb662d5af7db8bf81ca8aa34c979063e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Revision/RenderedRevision.php b/includes/Revision/RenderedRevision.php index 4acb9c0a64..3bc8dda578 100644 --- a/includes/Revision/RenderedRevision.php +++ b/includes/Revision/RenderedRevision.php @@ -292,6 +292,7 @@ class RenderedRevision implements SlotRenderingProvider { $this->setRevisionInternal( $rev ); $this->pruneRevisionSensitiveOutput( + $this->revision->getPageId(), $this->revision->getId(), $this->revision->getTimestamp() ); @@ -300,28 +301,38 @@ class RenderedRevision implements SlotRenderingProvider { /** * Prune any output that depends on the revision ID. * + * @param int|bool $actualPageId The actual page id, to check the used speculative page ID + * against; false, to not purge on vary-page-id; true, to purge on vary-page-id + * unconditionally. * @param int|bool $actualRevId The actual rev id, to check the used speculative rev ID - * against, or false to not purge on vary-revision-id, or true to purge on + * against,; false, to not purge on vary-revision-id; true, to purge on * vary-revision-id unconditionally. * @param string|bool $actualRevTimestamp The actual rev timestamp, to check against the - * parser output revision timestamp, or false to not purge on vary-revision-timestamp + * parser output revision timestamp; false, to not purge on vary-revision-timestamp; + * true, to purge on vary-revision-timestamp unconditionally. */ - private function pruneRevisionSensitiveOutput( $actualRevId, $actualRevTimestamp ) { + private function pruneRevisionSensitiveOutput( + $actualPageId, + $actualRevId, + $actualRevTimestamp + ) { if ( $this->revisionOutput ) { if ( $this->outputVariesOnRevisionMetaData( $this->revisionOutput, + $actualPageId, $actualRevId, $actualRevTimestamp ) ) { $this->revisionOutput = null; } } else { - $this->saveParseLogger->debug( __METHOD__ . ": no prepared revision output...\n" ); + $this->saveParseLogger->debug( __METHOD__ . ": no prepared revision output" ); } foreach ( $this->slotsOutput as $role => $output ) { if ( $this->outputVariesOnRevisionMetaData( $output, + $actualPageId, $actualRevId, $actualRevTimestamp ) ) { @@ -384,64 +395,77 @@ class RenderedRevision implements SlotRenderingProvider { /** * @param ParserOutput $out - * @param int|bool $actualRevId The actual rev id, to check the used speculative rev ID - * against, false to not purge on vary-revision-id, or true to purge on + * @param int|bool $actualPageId The actual page id, to check the used speculative page ID + * against; false, to not purge on vary-page-id; true, to purge on vary-page-id + * unconditionally. + * @param int|bool $actualRevId The actual rev id, to check the used speculative rev ID + * against,; false, to not purge on vary-revision-id; true, to purge on * vary-revision-id unconditionally. * @param string|bool $actualRevTimestamp The actual rev timestamp, to check against the - * parser output revision timestamp, false to not purge on vary-revision-timestamp, - * or true to purge on vary-revision-timestamp unconditionally. + * parser output revision timestamp; false, to not purge on vary-revision-timestamp; + * true, to purge on vary-revision-timestamp unconditionally. * @return bool */ private function outputVariesOnRevisionMetaData( ParserOutput $out, + $actualPageId, $actualRevId, $actualRevTimestamp ) { - $method = __METHOD__; + $logger = $this->saveParseLogger; + $varyMsg = __METHOD__ . ": cannot use prepared output for '{title}'"; + $context = [ 'title' => $this->title->getPrefixedText() ]; if ( $out->getFlag( 'vary-revision' ) ) { // If {{PAGEID}} resolved to 0, then that word need to resolve to the actual page ID - $this->saveParseLogger->info( - "$method: Prepared output has vary-revision..." - ); + $logger->info( "$varyMsg (vary-revision)", $context ); return true; - } elseif ( $out->getFlag( 'vary-revision-id' ) + } elseif ( + $out->getFlag( 'vary-revision-id' ) && $actualRevId !== false && ( $actualRevId === true || $out->getSpeculativeRevIdUsed() !== $actualRevId ) ) { - $this->saveParseLogger->info( - "$method: Prepared output has vary-revision-id with wrong ID..." - ); + $logger->info( "$varyMsg (vary-revision-id and wrong ID)", $context ); return true; - } elseif ( $out->getFlag( 'vary-revision-timestamp' ) + } elseif ( + $out->getFlag( 'vary-revision-timestamp' ) && $actualRevTimestamp !== false && ( $actualRevTimestamp === true || $out->getRevisionTimestampUsed() !== $actualRevTimestamp ) ) { - $this->saveParseLogger->info( - "$method: Prepared output has vary-revision-timestamp with wrong timestamp..." - ); + $logger->info( "$varyMsg (vary-revision-timestamp and wrong timestamp)", $context ); + return true; + } elseif ( + $out->getFlag( 'vary-page-id' ) + && $actualPageId !== false + && ( $actualPageId === true || $out->getSpeculativePageIdUsed() !== $actualPageId ) + ) { + $logger->info( "$varyMsg (vary-page-id and wrong ID)", $context ); 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..." - ); + $logger->info( "$varyMsg (vary-revision-exists)", $context ); + return true; + } elseif ( + $out->getFlag( 'vary-revision-sha1' ) && + $out->getRevisionUsedSha1Base36() !== $this->revision->getSha1() + ) { + // If a self-transclusion used the proposed page text, it must match the final + // page content after PST transformations and automatically merged edit conflicts + $logger->info( "$varyMsg (vary-revision-sha1 with wrong SHA-1)", $context ); 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 - // targeting the user making the null-edit, not the user who made the original edit, - // causing {{REVISIONUSER}} to return the wrong name. - // This case is now expected to be handled by the code in RevisionRenderer that - // constructs the ParserOptions: For a null-edit, setCurrentRevisionCallback is called - // with the old, existing revision. - - $this->saveParseLogger->debug( "$method: Keeping prepared output..." ); - return false; } - } + // 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 + // targeting the user making the null-edit, not the user who made the original edit, + // causing {{REVISIONUSER}} to return the wrong name. + // This case is now expected to be handled by the code in RevisionRenderer that + // constructs the ParserOptions: For a null-edit, setCurrentRevisionCallback is called + // with the old, existing revision. + $logger->debug( __METHOD__ . ": reusing prepared output for '{title}'", $context ); + return false; + } }