Page MenuHomePhabricator

Discussion Tools causes TemplateStyles to be empty in certain cases
Closed, ResolvedPublic

Description

It looks like the current version of Discussion Tools causes TemplateStyles not to load properly in certain cases.

E.g. the welcome message Template:Hola on nl.wp uses TemplateStyles;

The pages 16–45 contain an empty <style data-mw-deduplicate="TemplateStyles:r56789563"></style> when Discussion Tools is enabled.


[1] The welcome message as it should look (:c):

Hola_nr_1.PNG (557×976 px, 75 KB)

[2] The welcome message without the TemplateStyles styling (:c):
Hola_nr_2.PNG (823×980 px, 82 KB)

Event Timeline

The inserting of 'top-level' <span data-mw-comment="..."> elements may have something to do with the issue, but that's just my guess.
See also WP:SHEIC, the technical village pump on nl.wp (so in Dutch), for some discussion leading to this ticket.

Thanks for the bug report, and for the examples.

It looks like the problem occurs when there is a signature following the welcome template. This causes our code to treat it like any other comment, and insert the reply link into the page. The link also comes with two markers to indicate the start and end of a comment [1]. It looks like our code tries to insert the start marker inside of the <style> tag, which is not allowed in HTML, and which causes the contents of the tag to not be serialized into HTML at all. (We've recently had a similar issue caused by the end marker appearing inside of a <br> tag: T266288.)

[1] They look like this in HTML: <span data-mw-comment-start="c|Danielm|2004-08-22T21:10:00.000Z"></span> <span data-mw-comment-end="c|Danielm|2004-08-22T21:10:00.000Z"></span>

Change 649413 had a related patch set uploaded (by Bartosz Dziewoński; owner: Bartosz Dziewoński):
[mediawiki/extensions/DiscussionTools@master] Fix trying to insert start/end markers in impossible locations

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

Change 649413 merged by jenkins-bot:
[mediawiki/extensions/DiscussionTools@master] Fix trying to insert start/end markers in impossible locations

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

matmarex edited projects, added Skipped QA; removed Patch-For-Review.

The fix will be included in this week's deployment on Thursday.

Thanks for the quick investigation and fix!

Meta: I'm going to check this on Friday, 18-Dec.

Meta: I'm going to check this on Friday, 18-Dec.

This seems to be working as expected to me. [i]

@Marc if you observe otherwise, please re-open this task.


ppelberg claimed this task.

Ah yes, last week I noticed it works fine after the update (but forgot to mention it here). Thanks!

Ah yes, last week I noticed it works fine after the update (but forgot to mention it here). Thanks!

Excellent ^ _ ^

Bdijkstra added a subscriber: Bdijkstra.

Re-opened, it seems that a regression happened. Same symptom on some user pages: link 16 above looks fine to me, but not link 17.

Also noticed on huwiki: Szerkesztővita:Merkl.otto and Szerkesztővita:Merkl, on both pages the In memoriam… ({{gyász}}) template lacks styling.

I think it's a separate issue. The fix here is covered by unit tests and they're still passing, so it's not just a silly regression. The problem now occurs only on pages where a comment using TemplateStyles appears before any section headings. I don't know yet how we broke that but I'll investigate.

Filed a separate task: T275440: Discussion Tools causes TemplateStyles to be empty in certain cases on pages without section headings