Page MenuHomePhabricator

DiscussionTools's reply tool doesn't work when the comments are transcluded from another page using a template (not directly)
Open, MediumPublic

Description

DiscussionTools's reply tool doesn't work when the comments are transcluded from another page using a template (not directly).

Open questions

  • 1. Are there adjustments projects can make to the templates they are using to achieve the same result while also being compatible with how the Reply Tool currently works?

Examples

Example 1: ko.wp featured article discussions

(originally reported here: https://ko.wikipedia.org/wiki/위키백과:사랑방_(기술)/2020년_7월#Reply_tool_as_a_Beta_Feature)

DiscussionTools doesn't work on featured article discussions on ko.wp, e.g. on this page: https://ko.wikipedia.org/wiki/위키백과:알찬_글_후보

Reply links appear, but the widget doesn't open, instead showing the error:

The "답변" link cannot be used to reply to this comment. To reply, please use the full page editor by clicking "원본 편집".

The reply links don't work because the subpages with discussions are transcluded using the template 알찬 글 토론 rather than directly (e.g. {{알찬 글 토론|로드 (가수)}} rather than {{위키백과:알찬 글 후보/로드 (가수)}}), in order to add the collapsible box around each discussion, so our tool isn't able to find the page where the comments are really written (and where the replies should be added).

We should investigate and see if we can add support for this case.

Ed: Example in English:

Template:Discussion
{{:Discus/{{{1}}}}}
Discus/Test
Hello world
Test
{{Discussion|Test}}

The final page Test outputs Hello world:

<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Discussion","href":"./Template:Discussion"},"params":{"1":{"wt":"Test"}},"i":0}}]}' id="mwAg">Hello world</p>

There is no mention of Discus/Test in the HTML output

HTML of the template page:

<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":":Discus/{{{1}}}","href":"./Discus/"},"params":{},"i":0}}]}' id="mwAg">{{:Discus/{{{1}}}}}</p>

DiscussionTools needs to recurse into each transclusion level, one by one, in order to identify the "real" page holding a given reply or topic, but currently this only works when the transclusion does not have parameters. Although Parsoid generates mw:Param markup for parameters out in free text, there is no mw:Param markup in the mw:Transclusion above, just unparsed wikitext {{{1}}}.

Example 2: pt.wp article merge discussions

Similar situation where a discussion page is transcluded using a template: https://pt.wikipedia.org/wiki/Discussão:Feudalismo

Example 3: en.wp The Signpost

Similar problem affects the comments sections of English Wikipedia's The Signpost, such as this one: https://en.wikipedia.org/wiki/Wikipedia:Wikipedia_Signpost/2021-06-27/Forum#comments (in this case the discussion is transcluded from the talk page: https://en.wikipedia.org/wiki/Wikipedia_talk:Wikipedia_Signpost/2021-06-27/Forum).

Event Timeline

Esanders updated the task description. (Show Details)

This is the 'nested data-mw' issue, where the outer template includes an inner template, but the data-mw for the inner template (which says which template *actually* got included). This is a case of T214241: data-mw info is clobbered by template annotations...

...but there's a second issue here, which is that generally speaking we strip parsoid markup in the inner templates, in order to avoid bloating the payload. So stripping the second level of indirection is "by design".

Here's a short parser test which demonstrates the issue, more or less:

!! article
Template:Include
!! text
This is the thing included:

{{ {{{1}}} }}
!! endarticle

!! test
Including an include
!! wikitext
{{Include|:Main Page}}
!! html/parsoid
<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Include","href":"./Template:Include"},"params":{"1":{"wt":":Main Page"}},"i":0}}]}'>This is the thing included:</p>
<span> </span>
<p>blah blah</p>
!! end

Note that the Parsoid markup has lost all information about the fact that it is actually [[Main Page]] which is being included.

DiscussionTools currently does follow the chain of transclusions (up to ten deep) so if {{Foo}} is included it asks RESTBase for the parsoid HTML for Foo and then proceeds to work on that. But if the transclusion is {{Foo|Bar}} there's currently no way to ask RESTBase to render "Foo" with parameter "Bar", so there's no way to properly recurse.

Something like the following is present in the nested transclude:

<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Discussion/{{{1}}}","href":"./Template:Discussion"},"i":0}}]}' id="mwAg">

So while it's pretty ugly, I think I'm suggesting that the short term strategy is to regexp-match parts[1].template.target.wt against {{{\d}}} and to substitute in the parameter (from the parts[1].template.params of the parent) in that case when DiscussionTools manually does the recursion.

The "proper" solution will be to add a params parameter to the RESTBase/ParserCache/Parsoid API to ask specifically for an expansion of [[Title]] with specific parameters X and Y etc. (Are X and Y specified in wikitext, HTML, ?) This would then get cached and bring us one step closer to our incremental parsing roadmap. But that's going to be a long term project to hammer out that API, especially given the state of flux of RESTBase/ParserCache, so the ugly approach above is probably best for now.

@Whatamidoing-WMF shared that her team hasn't found any templates they encounter regularly, asked village pump tech today and should have more information tomorrow. There has been a lot of innovation from that community.

@Whatamidoing-WMF shared that her team hasn't found any templates they encounter regularly, asked village pump tech today and should have more information tomorrow. There has been a lot of innovation from that community.

Sherry and I talked about this today. We have not yet received responses about this convention at en.wiki's Village Pump Technical. [i]

Next, we'll reach out to ko.wiki to learn more about the convention.

From the Editing Team's perspective, we're going to wait on addressing this issue in software until we have evidence of the following:

  • The 알찬 글 토론 template is used widely at ko.wiki
  • The functionality the 알찬 글 토론 template achieves cannot be achieved in a way that is compatible with the Reply Tool.

Next steps

  • @Whatamidoing-WMF is going to ask volunteers at ko.wiki how widely this convention is used at ko.wiki and how it came to be used there.

i. https://en.wikipedia.org/wiki/Wikipedia:Village_pump_(technical)#Looking_for_page_transclusion_templates

AFAICT, from the end-user's perspective, this error, and the workaround, are the same as any page that uses open tags to create a colored background or other fancy formatting, e.g., https://en.wikipedia.org/wiki/Wikipedia_talk:WikiProject_COVID-19

Also, even if this technical problem were fixed, I think you still couldn't use the Reply tool, because you can't edit sections with {{collapse top}} and {{collapse bottom}} around them anyway.

That's a slightly different case, this one should be somewhat easier to solve, since the comments are written on a separate page without wrapper templates like that.

Next steps

  • @Whatamidoing-WMF is going to ask volunteers at ko.wiki how widely this convention is used at ko.wiki and how it came to be used there.

@Whatamidoing-WMF reached out to volunteers at ko.wiki [i]. We determined this is not high priority at this time.


i. https://ko.wikipedia.org/wiki/%EC%9C%84%ED%82%A4%EB%B0%B1%EA%B3%BC:%EC%82%AC%EB%9E%91%EB%B0%A9_(%EA%B8%B0%EC%88%A0)/2020%EB%85%84_7%EC%9B%94

Similar situation where a discussion page is transcluded using a template: https://pt.wikipedia.org/wiki/Discussão:Feudalismo

Similar problem affects the comments sections of English Wikipedia's The Signpost, such as this one: https://en.wikipedia.org/wiki/Wikipedia:Wikipedia_Signpost/2021-06-27/Forum#comments (in this case the discussion is transcluded from the talk page: https://en.wikipedia.org/wiki/Wikipedia_talk:Wikipedia_Signpost/2021-06-27/Forum).

matmarex renamed this task from DiscussionTools doesn't work on featured article discussions on ko.wp to DiscussionTools's reply tool doesn't work when the comments are transcluded from another page using a template (not directly).Nov 8 2021, 9:06 PM
matmarex updated the task description. (Show Details)
Trizek-WMF subscribed.

New case. As it is a painful, recurring problem, I thin we should discuss it one more time.

If you have

<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Discussion","href":"./Template:Discussion"},"params":{"1":{"wt":"Test"}},"i":0}}]}' id="mwAg">Hello world</p>

couldn’t you pre-save transform {{subst:Discussion|1=Test}} and then look for transclusions in the result? Or send {{Discussion|1=Test}} through what Special:ExpandTemplates uses if it’s Parsoid-compatible yet?