Page MenuHomePhabricator

[1.38.0-wmf.7] WikidataPageBanner: Disable mechanism of table of contents is no longer working on preview mode
Closed, ResolvedPublicBUG REPORT

Description

List of steps to reproduce (step by step, including full links if applicable):

  • Pages should not have table of contents in preview mode (just like the view mode as per T295003)

What happens?:
For some reason, the table of contents are coming up on Wikivoyage on preview mode, which is not usually normal. The affected language versions (for example) are: en:voy, fr:voy, ru:voy.
it:voy is not affected, although apparently the template looks equivalent.
Compare the preview mode of the following two pages:

What should have happened instead?:
The table of contents should have been restricted to the pagebanner

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc:

QA steps

beta cluster

Visit https://en.wikivoyage.beta.wmflabs.org/wiki/Bannerda?action=edit and click "show preview" button
Expected: The vertical table of contents should not be present in the page. It should be present inside the banner image at the top of the page as a horizontal bar.

WRONGCORRECT
Screen Shot 2021-12-06 at 4.43.21 PM.png (1×2 px, 1 MB)
Screen Shot 2021-12-06 at 4.43.43 PM.png (1×1 px, 1 MB)

Production

Visit https://en.wikivoyage.org/w/index.php?title=Emilia-Romagna&action=edit & press "Show preview" button.
Expected: The vertical table of contents should not be present in the page. It should be present inside the banner image at the top of the page as a horizontal bar.

QA Results - Beta

ACStatusDetails
1T295632#7577707

QA Results - Prod

ACStatusDetails
1T295632#7577712

Event Timeline

@cscott as per @Jdlrobson request, I've added you on this ticket to check the issue during his two weeks absence. Thanks in advance for your support.

ovasileva triaged this task as Medium priority.Nov 16 2021, 6:02 PM

@cscott we are going to need a new core hook to restore this behaviour:

diff --git a/includes/EditPage.php b/includes/EditPage.php
index 243042cee6..79ac2f81f0 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -4250,6 +4250,20 @@ class EditPage implements IEditObject {
                $pstContent = $contentTransformer->preSaveTransform( $content, $this->mTitle, $user, $parserOptions );
                $scopedCallback = $parserOptions->setupFakeRevision( $this->mTitle, $pstContent, $user );
                $parserOutput = $contentRenderer->getParserOutput( $pstContent, $this->mTitle, null, $parserOptions );
+               // @todo: Hook needed here to allow WikidataPageBanner to disable table of contents with code below:
+               if ( $parserOutput->getExtensionData( 'wpb-banner-options' ) !== null ) {
+                       $options = $parserOutput->getExtensionData( 'wpb-banner-options' );
+                       $tocInBanner = $options['enable-toc'] ?? false;
+                       if ( $tocInBanner ) {
+                               $parserOutput->setText(
+                                       Parser::replaceTableOfContentsMarker(
+                                               $parserOutput->getRawText(),
+                                               ''
+                                       )
+                               );
+                       }
+               }
+               // @todo: end book.
                ScopedCallback::consume( $scopedCallback );
                return [
                        'parserOutput' => $parserOutput,

While testing this I also note that table of contents shows up in previews of skins that don't want it. I am going to suggest a more generic hook that allows extensions to explicitly disable the table of contents....

Change 743268 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/WikidataPageBanner@master] Disable main article table of contents in a less hacky way

https://gerrit.wikimedia.org/r/743268

No need for a new hook in the end. This one works great.

Change 743268 merged by jenkins-bot:

[mediawiki/extensions/WikidataPageBanner@master] Disable main article table of contents in a less hacky way

https://gerrit.wikimedia.org/r/743268

Test Result - Beta

Status: ✅ PASS
Environment: beta
OS: macOS Monterey
Browser: Chrome
Device: MBP
Emulated Device:NA

Test Artifact(s):

QA Steps

Visit https://en.wikivoyage.beta.wmflabs.org/wiki/Bannerda?action=edit and click "show preview" button
✅ AC1: Expected: The vertical table of contents should not be present in the page. It should be present inside the banner image at the top of the page as a horizontal bar.

Screen Shot 2021-12-17 at 6.36.35 AM.png (831×958 px, 345 KB)

Edtadros subscribed.

Test Result - Prod

Status: ✅ PASS
Environment: Prod
OS: macOS Monterey
Browser: Chrome
Device: MBP
Emulated Device:NA

Test Artifact(s):

QA Steps

Visit https://en.wikivoyage.org/w/index.php?title=Emilia-Romagna&action=edit & press "Show preview" button.
✅ AC1: Expected: The vertical table of contents should not be present in the page. It should be present inside the banner image at the top of the page as a horizontal bar.

Screen Shot 2021-12-17 at 6.40.18 AM.png (875×1 px, 510 KB)