Page MenuHomePhabricator

Templated link is editable as text
Closed, InvalidPublic

Description

Templated link is editable as text on this page: https://de.wikipedia.org/wiki/Heute?veaction=edit

The wikitext used there is:
* ''heute'', der gegenwärtige Tag: [[{{LOCALDAY}}. {{LOCALMONTHNAME}}]] [[{{LOCALYEAR}}]]

I would expect the two links to be treated like transclusions, but they behave like regular links (and editing them loses the templates):

image.png (2×3 px, 530 KB)

image.png (2×3 px, 591 KB)

The markup is like this: (https://de.wikipedia.org/api/rest_v1/page/html/Heute/197466416)

<a typeof="mw:ExpandedAttrs" about="#mwt3" rel="mw:WikiLink" href="./11._Oktober" title="11. Oktober" data-mw='{"attribs":[[{"txt":"href"},{"html":"&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&apos;{\"pi\":[[]],\"dsr\":[62,74,null,null]}&apos; data-mw=&apos;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"LOCALDAY\",\"function\":\"localday\"},\"params\":{},\"i\":0}}]}&apos;>11&lt;/span>. &lt;span about=\"#mwt2\" typeof=\"mw:Transclusion\" data-parsoid=&apos;{\"pi\":[[]],\"dsr\":[76,94,null,null]}&apos; data-mw=&apos;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"LOCALMONTHNAME\",\"function\":\"localmonthname\"},\"params\":{},\"i\":0}}]}&apos;>Oktober&lt;/span>"}]]}' id="mwBw">11. Oktober</a>

Looks like we have no code to handle typeof="mw:ExpandedAttrs". It is documented here: https://www.mediawiki.org/wiki/Specs/HTML/2.1.0#Generated_attributes_of_HTML_tags

Event Timeline

I think this is partially also a Parsoid problem – both the link label and the link target are generated by a transclusion, but in the markup, it's only indicated that the link target is generated.

The documentation I linked states: "When only attributes are affected, the element is be assigned an mw:ExpandedAttrs typeof attribute (…). If other parts of the content are also transclusion-affected, the element will be marked up as a general transclusion instead."

I would expect either:

  • Another <span typeof="mw:Transclusion">…</span> nested inside the <a typeof="mw:ExpandedAttrs">…</a>, to indicate that link label is generated by a transclusion, or
  • A single element with typeof="mw:Transclusion" in place of typeof="mw:ExpandedAttrs" that would be generated from [[, template, ]].

What is the problem? If you edit the link text (and save or review changes), you see [[{{LOCALDAY}}. {{LOCALMONTHNAME}}|11th Oktober blah blah]] which is just fine. It is valid wikitext and represents the edit as well.

When editing, there is no indication that the text is coming from a template/PF (and in this particular case, no indication that it automatically updates to today's date). Together with excessive caching causing the wrong date to appear in the editor (T265196), one could easily think that they should update the date manually when editing the page, and thus break the automatic updates.

Ya, caching is a different issue. As Parsoid starts generating all the same metadata that core does, that issue will get resolved. In general, even in wikitext like this [[{{LOCALDAY}}. {{LOCALMONTHNAME}}]] there is nothing preventing me from editing source to say [[{{LOCALDAY}}. {{LOCALMONTHNAME}}| 11th Oktober blah blah]]. How would VE know what link text is okay to edit and what is not? One option is for Parsoid to generate special markup for some subset of parser functions to prevent any editing of pieces of it. That will require some research to figure out what might be appropriate, but in the generic template link case [[{{1x|Foobar}}]], it is perfectly okay to edit just the link text.

But, I suppose you want Parsoid to add additional info in data-mw.attributes to indicate that the content was also templated, i.e. distinguish between [[{{1x|Foobar}}|blah]] and [[{{1x|Foobar}}]]. This piece of the code has not received a lot of attention from us since VE never made use of this info. But, I will create a separate ticket for this bit.