Page MenuHomePhabricator

Can't unset the group of a <ref>/<references> list in VisualEditor
Closed, ResolvedPublicBUG REPORT

Description

Steps to reproduce:

  • Start a blank page and add this wikitext:
<ref group="note">a</ref>
==Notes==
<references group="note" />
==General references==
<references />
  • Switch to VisualEditor.
  • Edit the <ref> and change the group from "note" to "General references". For the moment it looks like this works as expected.
  • Click "Publish changes" and "Review your changes". The visual diff looks correct, but the wikitext diff still shows the group="note" that shouldn't be there any more. Yes, the two diffs are actually out of sync at this point.
  • Switch back to the wikitext editor, or just save the page. In either case the group="note" is not removed.

The same thing happens when editing the <references> tag:

  • Start a blank page with nothing but <references group="note" />. (This will render as an empty page. Don't be confused. This is correct.)
  • Switch to VisualEditor, edit the reference list, and remove the group. As above, it appears like this works, but the group won't disappear from the wikitext serialization.

The issue is the same in both cases, in two unrelated lines of code: https://gerrit.wikimedia.org/r/1005500

Event Timeline

Change 1005500 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/Cite@master] Fix broken deletion of non-existing <ref refGroup="…">

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

Change 1005500 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Fix broken deletion of non-existing <ref refGroup="…">

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

Those original lines (delete mwData.attrs.refGroup; rather than delete mwData.attrs.group;) have been that way for a very long time -- at least since 2016. Not sure if it's been broken the whole time, or if the name of the attribute coming from parsoid shifted at some point...

My understanding is that the mw data structure with its body and attrs is a 1:1 representation of what can be seen in the wikitext. We know the attribute was always called <ref group="…">. From what I have seen Parsoid just passes this along. Because of this I'm relatively sure this was really a copy-paste mistake. I suspect the feature (removing a group) is just never used, or used so rarely that it never made it into a bug report. The effect is also quite confusing. The user probably thinks they made a mistake.

The bug exists ever since the group was made editable in VisualEditor in 2013, see https://gerrit.wikimedia.org/r/67466. The second instance in https://gerrit.wikimedia.org/r/69832 was probably copy-pasted from the first.