Page MenuHomePhabricator

JS pages show ToCs in vector-2022
Closed, ResolvedPublicBUG REPORT

Description

Page: https://en.wikipedia.org/wiki/MediaWiki:Gadget-popups.js

This contains raw <h2> elements. Because we parse JS pages in wikitext mode (for backlink support and categorization), but render them without wikitext mode, this page does actually have a ToC. It just never used to be visible until now.

Screenshot 2022-05-05 at 15.56.54.png (428×717 px, 82 KB)

Not sure what the best strategy for a fix here is, modify the script, or think about if we maybe should not present ToCs for certain content models (or both).

QA steps

QA Results - Beta

ACStatusDetails
1T307691#8135559

QA Results - Prod

ACStatusDetails
1T307691#8135562

Event Timeline

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

[mediawiki/core@master] Do not transfer sections to OutputPage for site config

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

Jdlrobson added a subscriber: cscott.

@cscott I think this is a bug in parser/Article handling. Could I please request a review on the above patch?

This is an interesting issue.

The "right" way to handle this is to set a flag in the ParserOutput to say "don't render the TOC". But we didn't actually do it that way, what we did was to elect "not to include the TOC marker element" in that case, and then rely on the substitution to find no match when it tries to insert the TOC -- and explicitly rely on the theme otherwise.

The Gadget-popups.js page could include:

// __NOTOC__

to work around this problem. But I think it would be better to suppress setSections() pre-emptively on "code type content", as @Krinkle suggests in his review on the above patch. In theory that could be done by the appropriate Content class calling:

$parserOutput->setPageProperty('notoc', '');

but unfortunately Parser only writes this page property, it doesn't read it. So I think probably a flag needs to be added to ParserOptions, so that code-type Content can set this when parsing.

Then the Parser will use its standard "notoc" handling and not set the section data on ParserOutput, which means that it won't get passed to OutputPage, and we'll have fixed this problem without an explicit hack in OutputPage.

Separately, we might want to indicate "no toc" status explicitly as a ParserOutput flag (instead of implicitly through "lack of a marker in the HTML") so that the skin can more carefully distinguish between "TOC is active, but no entries exist" and "TOC deliberately suppressed for this content type or by user request". But this latter task isn't a blocker.

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

[mediawiki/core@master] Certain content handlers should disable table of contents generation

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

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

[mediawiki/core@master] Define background size on logos with 1x and icon keys

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

Change 791659 abandoned by Jdlrobson:

[mediawiki/core@master] Do not transfer sections to OutputPage for site config

Reason:

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

Could someone clarify the code path here? We're rendering as Wikitext and generating a ParserOutput for category/backlink/etc purposes, then throwing away the generated HTML and rendering the code as preformatted text (or some such) instead?

Change 800765 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/core@master] Add ParserOption to suppress TOC when parsing non-wikitext pages

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

Change 805897 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/core@master] Use ParserOptions::setSuppressTOC() for Javascript content

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

Change 806228 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/core@master] Use ParserOptions::setSuppressTOC() for Javascript content (option 2)

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

Change 806229 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/core@master] Use canonical parser options when rendering Javascript pages for side effects

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

Change 805897 abandoned by C. Scott Ananian:

[mediawiki/core@master] Use ParserOptions::setSuppressTOC() for Javascript content (option 1)

Reason:

Abandoned in favor of Iba6a8b6c59bf91e3d06896f0a610c3c3e52e6564

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

Change 793537 abandoned by Jdlrobson:

[mediawiki/core@master] Certain content handlers should disable table of contents generation

Reason:

Abandoning in favor of https://gerrit.wikimedia.org/r/c/mediawiki/core/+/806228

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

My understanding is that web team is waiting on the content transform's patch https://gerrit.wikimedia.org/r/c/mediawiki/core/+/806228/ which is blocked on review by Daniel. Is this correct?

JMcLeod_WMF subscribed.

Removed the content-transform-team tag; the Content Transform Team will deal with this under the MediaWiki-Parser project. It should be completed in the next week.

Waiting for a review from @daniel on https://gerrit.wikimedia.org/r/c/mediawiki/core/+/800765 and https://gerrit.wikimedia.org/r/c/mediawiki/core/+/806228 although we can probably C+2 this w/in the content transform team if we need to.

Change 800765 merged by jenkins-bot:

[mediawiki/core@master] ParserOption/ParserOutput flag to suppress or hide the table of contents

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

Change 806228 merged by jenkins-bot:

[mediawiki/core@master] Use ParserOptions::setSuppressTOC() for Javascript content

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

Thanks for getting these fixed. Adding to our sprint board for QA!

Change 806229 merged by jenkins-bot:

[mediawiki/core@master] Use canonical parser options when rendering JavaScript/CSS for side effects

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

Edtadros subscribed.

Test Result - Beta

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

Test Artifact(s):

QA Steps

✅ AC1: Beta cluster: Confirm https://en.wikipedia.beta.wmflabs.org/wiki/MediaWiki:Gadget-popups.js has no table of contents

Screen Shot 2022-08-06 at 3.48.54 PM.png (1×2 px, 539 KB)

Edtadros added a subscriber: daniel.

Test Result - Prod

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

Test Artifact(s):

QA Steps

QA steps

AC1: Production - confirm https://en.wikipedia.org/wiki/MediaWiki:Gadget-popups.js has no table of contents

Screen Shot 2022-08-06 at 3.53.26 PM.png (1×2 px, 607 KB)

oops...I'm used to assigning it when I move the column. Just assigning this back.

Jdlrobson removed daniel as the assignee of this task.

This can be resolved

Change 974657 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/core@master] WikiPage: remove ::suppressTOC hack

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

Change 974657 merged by jenkins-bot:

[mediawiki/core@master] WikiPage: remove ::suppressTOC hack

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