From 3b2de5b10ed8e7f398e1b29727de6d33825f5c0c Mon Sep 17 00:00:00 2001 From: Subramanya Sastry Date: Wed, 14 Feb 2024 15:21:35 -0600 Subject: [PATCH] Properly handle preview scenario for Parsoid rendering * Removed a wikiech-specific hack and use the now available ParserOutput flag. Change-Id: Ia06025c131485a9dc67afd8258fa4b3753d165b9 --- includes/Hooks/ParserHooks.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/includes/Hooks/ParserHooks.php b/includes/Hooks/ParserHooks.php index a131f7cf2..f6e74f7b3 100644 --- a/includes/Hooks/ParserHooks.php +++ b/includes/Hooks/ParserHooks.php @@ -15,6 +15,7 @@ use MediaWiki\Extension\DiscussionTools\CommentFormatter; use MediaWiki\Hook\GetDoubleUnderscoreIDsHook; use MediaWiki\Hook\ParserAfterTidyHook; use MediaWiki\Hook\ParserOutputPostCacheTransformHook; +use MediaWiki\Parser\ParserOutputFlags; use MediaWiki\Parser\Parsoid\PageBundleParserOutputConverter; use MediaWiki\Parser\Parsoid\ParsoidParser; use MediaWiki\Title\Title; @@ -86,14 +87,7 @@ class ParserHooks implements * @inheritDoc */ public function onParserOutputPostCacheTransform( $parserOutput, &$text, &$options ): void { - // TEMPORARY for wikitech visualdiff testing: Pin this to false so we - // always render reply links (for anon users as well) to match current - // behavior which also lets us run a truer visual diff with DT. - // - // NOTE: This is a temporary proxy for 'isPreview' flag in ParserOptions. - // It is not clear whether 'editsectionEditLinks' is disabled only for previews. - // $isPreview = empty( $options['enableSectionEditLinks'] ); - $isPreview = false; + $isPreview = $parserOutput->getOutputFlag( ParserOutputFlags::IS_PREVIEW ); // We want to run this hook only on Parsoid HTML for now. // (and leave the onParserAfterTidy handler for legacy HTML).