Page MenuHomePhabricator

Usernames invisible in Echo notification text
Closed, ResolvedPublic

Description

I just got a notification because someone tagged me and a bunch of other usernames, and the notification text did not show those other usernames. The edit text contained (in Hebrew, alas) "I tagged [[User:Foo|Foo]], [[User:Bar|Bar]], [[User:Baz|Baz]], and [[User:Xyzzy|xyzzy]], ...", but the notification text looked like "I tagged , , , , ...."

See screenshot:

echo_bug.png (209×608 px, 24 KB)

Event Timeline

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

So it looks like EchoDiscussionParser::getTextSnippet() just strips all templates. I don't really understand why it works the way it does. For snippets of Flow discussions, we take the HTML version and strip it down. For wikitext discussions, we start with wikitext, strip tags, strip templates, THEN parse it, replace   with spaces, decode, strip tags AGAIN, remove { and } (why?!), then truncate.

Change 276687 had a related patch set uploaded (by Catrope):
Unconvolute DiscussionParser::getTextSnippet()

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

Other weird behavior in the old implementation:

  • Anything wrapped in / produced by a template was stripped. As the bug report says, this includes {{ping|Username}}, and it's very unhelpful to strip these
  • Including odd entities in comments (e.g. ὣ which is ὣ) caused no snippet to be shown at all
  • I have reason to believe { and } got removed wherever they appeared

These apply to wikitext mentions and edit-user-talk notifications; for Flow notifications, snippet behavior is much more sane. My patch basically takes the Flow logic and applies it to wikitext notifs.

  1. {{ping|Username}} produces - notice the added colon @Username:

{{FlowMention|Username}} will display @Username

{{ {{{|safesubst:}}}#time:i}} will display e.g. 06

{{CURRENTTIME}} will display e.g. 22:06

  1. ὣ will be displayed as ὣ

Note: Currently, wikitext User talk pages do not display text excerpts (except when a user was mentioned).

The test case to check after the fix:

-on a wikitext User talk page create a new section with a title: ὣ

  • in the body of that section Mention a user
  • the mentioned user receives broken notification

Screen Shot 2016-03-15 at 4.04.29 PM.png (186×613 px, 30 KB)

The rendered section looks like - also, View changes page: http://en.wikipedia.beta.wmflabs.org/w/index.php?title=User_talk:ET60&oldid=prev&diff=326673

Screen Shot 2016-03-15 at 4.07.47 PM.png (90×427 px, 10 KB)

Change 276687 merged by jenkins-bot:
Unconvolute DiscussionParser::getTextSnippet()

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

Checked in betalabs - a tricky topic title e.g. ὣ in Notifications is displayed properly.

Screen Shot 2016-03-22 at 3.22.55 PM.png (177×551 px, 34 KB)

However, @Catrope - an extra ὣ is added to the text excerpt. Also, it's displayed in the screenshot above - the first symbol of the text excerpt.
The following
Screen Shot 2016-03-22 at 3.29.42 PM.png (101×404 px, 15 KB)

was rendered as
Screen Shot 2016-03-22 at 3.29.27 PM.png (290×667 px, 43 KB)