Page MenuHomePhabricator

Customized messages mess order of DOM elements up
Closed, ResolvedPublic5 Story Points

Description

Some wikis do overwrite certain Cite messages in a way that HTML tags get rearranged, and additional ones added. This confuses the jQuery selectors we currently use in the JavaScript code.

Expected:

<sup>[[#$1|$2]]</sup>

Currently on https://en.wikipedia.org/w/index.php?title=MediaWiki:Cite_references_link_many_format&action=edit:

[[#$1|<sup>'''''$3'''''</sup>]]

The selector .mw-cite-backlink * a[href="#…"] assumes the <sup> comes before the <a>. This is critical, because the selector would otherwise include the <a …>↑</a>, and we don't want this to happen. It seems we need an other way to differentiate between the <sup><a …>… and (unexpected) <a …><sup>… we want, and the <a …>↑</a> we don't want.

  • One idea we had was to somehow count the number of <a>, and bail out if there is only one. But counting is hard if the <span class="mw-cite-backlink"> got removed.
  • Another idea is to check if there are at least two links, and check if the href of the second link ends with -1. This is not the case with the standard <a …>↑</a>, which always ends with -0.

Details

Related Gerrit Patches:

Event Timeline

thiemowmde triaged this task as High priority.Nov 28 2018, 11:13 AM

Change 476237 had a related patch set uploaded (by Thiemo Kreuz (WMDE); owner: Thiemo Kreuz (WMDE)):
[mediawiki/extensions/Cite@master] Make backlink highlighting robust for community customized HTML

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

Change 476241 had a related patch set uploaded (by WMDE-Fisch; owner: Thiemo Kreuz (WMDE)):
[mediawiki/extensions/Cite@wmf/1.33.0-wmf.6] Make backlink highlighting robust for community customized HTML

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

Change 476237 merged by jenkins-bot:
[mediawiki/extensions/Cite@master] Make backlink highlighting robust for community customized HTML

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

thiemowmde moved this task from Sprint Backlog to Review on the WMDE-QWERTY-Sprint-2018-11-20 board.

Change 476241 merged by jenkins-bot:
[mediawiki/extensions/Cite@wmf/1.33.0-wmf.6] Make backlink highlighting robust for community customized HTML

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

Stashbot added a subscriber: Stashbot.

Mentioned in SAL (#wikimedia-operations) [2018-11-28T12:43:12Z] <zfilipin@deploy1001> Synchronized php-1.33.0-wmf.6/extensions/Cite: SWAT: [[gerrit:476241|Make backlink highlighting robust for community customized HTML (T205270 T210520)]] (duration: 00m 55s)

WMDE-Fisch set the point value for this task to 5.Nov 28 2018, 3:56 PM
WMDE-Fisch moved this task from Review to Demo on the WMDE-QWERTY-Sprint-2018-11-20 board.

Demo:
Before these patches, the arrow linking on en.beta.wp /en.wp would not have worked/ Now it does, see e.g. https://en.wikipedia.beta.wmflabs.org/wiki/Barack_Obama#cite_ref-Harvard_Law_2007_96-0

Lea_WMDE closed this task as Resolved.Dec 3 2018, 10:31 AM
Lea_WMDE moved this task from Demo to Done on the WMDE-QWERTY-Sprint-2018-11-20 board.
Od1n added a subscriber: Od1n.Sep 5 2019, 12:41 PM

For the record, on frwiki I have changed the classname back to the regular name (refs Cite references link one, Cite references link many), as I think it's the only proper way to handle this. The classname just shouldn't had been allowed to be renamed in the first place. Triggered by the custom name, these subsequent JavaScript workarounds were in turn causing some bug in gadget ReferenceTooltips...