Page MenuHomePhabricator

Indicators in templates (PTag - phab page indicator; Geo (wikivoyage maps)) broken with Parsoid (mediawiki, metawiki, enwikivoyage)
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

Open https://www.mediawiki.org/wiki/Parsoid?useparsoid=1.

Look at the Phab page indicator.

What happens?:

It displays

Issue tracker: [[phab:tag/{{{1}}}/|#{{{1}}}]]

What should have happened instead?:

It should display

Issue tracker: #parsoid

with a link to the phab tag.

Other information (browser name/version, screenshots, etc.):

The fact that the issue stems from the PTag template rendering can be seen here: https://www.mediawiki.org/wiki/Template:Ptag?useparsoid=1

The issue is also visible on enwikivoyage, where all the uses of the Geo template (displaying a map next to the "Rendered with Parsoid" indicator) display a map centered on 0, 0. (see for instance https://en.wikivoyage.org/wiki/Zurich)

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

This doesn't seem like it needs access to the template frame stack (which is why we initially filed it under missing functionality) -- the {{ptag}} template is just:

<indicator name="phabricator-project">{{Badge|content=<translate><!--T:1--> [[<tvar name=1>Special:MyLanguage/Phabricator</tvar>|Issue tracker]]:</translate> [[phab:tag/{{lc:{{{1}}}}}/|'''#{{{1}}}''']]
}}</indicator>

And it seems that we're not fully recursing into that complex wikitext. We're parsing *some* of it, since the [[Issue tracker]] link is coming out, but the [[phab:tag/...]] business isn't.

That's probably just a plain-old parsing error of some sort.

While this feels related to T347507: ParsoidExtensionAPI: Provide a new method for extensions to access enclosing template parameters, I don't think that is the problem.

The issue is that the preprocessor should have processed the contents of indicator, but the preprocessor doesn't know to do that because it doesn't know that indicator content is wikitext.

@cscott yes .. we both landed on the same conclusion. :)

The thing is, this seems to work fine on enwiki, at least in my sandbox:
https://en.wikipedia.org/wiki/User:Cscott/T348722?useparsoid=1

The only thing I haven't copied here is the <translate> tags of the original, so I'm suspecting some interaction between annotations and the link parsing.

A small reproduction for this issue can be made by creating a template with the content

<span><indicator name="ptag">{{{1}}}</indicator></span>

(and then calling it with an arbitrary argument).

The problem is that, when we render an indicator, we parse the content of the extension as an independent document via $extApi->extTagToDOM, where the template frame and template arguments are not available anymore.

Hence, fixing T347507 might actually resolve this issue (and at least solve the issue of the availability of the frame arguments - which could then be passed somehow as a context to extTagToDOM).

Another solution/workaround would be to add a config option to tell the preprocessor to preprocess extension source recursively, so that it's already resolved when arriving in the extension.

ssastry renamed this task from PTag (phab page indicator) template on mediawikiwiki broken with Parsoid to PTag (phab page indicator) template broken with Parsoid (mediawiki, metawiki).Feb 24 2024, 3:22 PM
ihurbain renamed this task from PTag (phab page indicator) template broken with Parsoid (mediawiki, metawiki) to Indicators in templates (PTag - phab page indicator; Geo (wikivoyage maps)) broken with Parsoid (mediawiki, metawiki, enwikivoyage).Aug 5 2024, 12:43 PM
ihurbain updated the task description. (Show Details)

A small reproduction for this issue can be made by creating a template with the content

<span><indicator name="ptag">{{{1}}}</indicator></span>

(and then calling it with an arbitrary argument).

We could also add support for <indicator ... contents="{{{1}}}"> which would also solve the problem? For that matter, {{#tag:indicator|{{{1}}}|name=ptag}} should also work. The issue is that extension tag contents are explicitly "not wikitext" and so (in a purely formal sense) we shouldn't "expect" argument expansion to work inside there.

This also affects a template on wikivoyage; @ihurbain knows the details.

The thing is, this seems to work fine on enwiki, at least in my sandbox:
https://en.wikipedia.org/wiki/User:Cscott/T348722?useparsoid=1

The reported issue does show up on en.wp at AIV:

image.png (150×1 px, 25 KB)