Page MenuHomePhabricator

VisualEditor changed reference names when reusing/copying references
Open, Needs TriagePublic

Description

https://www.mediawiki.org/wiki/Topic:Wy2wfdklphqhu5c9

See this diff, which introduced several undefined references. Not sure if this is related to the issues I brought up a few months ago at Topic:Wn1ny31j08nr1rnr.

See also this diff – looks like possibly a similar problem. Based on context, it looks like the editor tried to copy the ref named ":0", but VisualEditor added a "2" to create the ref name ":02".

Here too - it looks like the refs named ":62", ":622", ":623", and ":624" are all intended to be the same reference.

Event Timeline

I haven't been able to reproduce, but looking closely at the diffs and other edits by the same users, this seems to be related to copy-pasting from outside the editor (either from another visual editor they have open in another tab, or maybe copy-pasting wikitext into the visual mode).

See this diff, which introduced several undefined references. Not sure if this is related to the issues I brought up a few months ago at Topic:Wn1ny31j08nr1rnr.

The content is pasted from this version in the user's sandbox: https://en.wikipedia.org/w/index.php?title=User:Clockwisecrocodile/sandbox&oldid=1080751440

See also this diff – looks like possibly a similar problem. Based on context, it looks like the editor tried to copy the ref named ":0", but VisualEditor added a "2" to create the ref name ":02".

The content is pasted from a previous revision: https://en.wikipedia.org/w/index.php?diff=1088550483&oldid=1088508500&title=Mick_Wallace

Here too - it looks like the refs named ":62", ":622", ":623", and ":624" are all intended to be the same reference.

The "Turkewitz" reference has been copied from their previous edits in Defamation and César Acuña (and in the Defamation diff, the same reference appears twice with different names, which also hints it has been copy-pasted from another page – that's T272251)


(there's nothing wrong about any of this, I'm just trying to figure out how the edits happened)

I've spent an hour copying and pasting references, and reading the code that does it, and I haven't found a way to break it.

It's not impossible that we have a bug, but right now I think that this probably happened because the users have pasted wikitext into the visual editor. If the pasted wikitext doesn't include the content of the reference, doing so produces this effect.

I'm wondering how we could prevent that. We could highlight the broken reference in the editor, but that would result in many false warnings about references whose contents are defined in templates. Maybe we should just drop these references entirely when pasting? I'm not sure if that is more helpful for the user, but it would prevent the editor from being blamed for the error…

Change 814363 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/extensions/VisualEditor@master] [WIP] Filter out references with no content when pasting wikitext

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

Change 814363 abandoned by Bartosz Dziewoński:

[mediawiki/extensions/VisualEditor@master] [WIP] Filter out references with no content when pasting wikitext

Reason:

Not a good idea, see task

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

One more example from the topic: https://en.wikipedia.org/w/index.php?title=Beauty_and_the_Beast_%282017_film%29&diff=prev&oldid=1098930773

In this diff, the user was just trying to remove the {{Cast listing|…}} template wrapper, in addition to the other changes. The only way to do it is to copy-paste the wikitext out of the template. When I do this, I get the same diff with changed ref names that that they got:

I think that confirms my theory, but it also suggests that my proposed fix (just removing the broken refs) is not a good idea. I guess we should try to match the names to the existing ones, rather than filter them out. But this can lead to conflicts when refs are copy-pasted between articles… (particularly with the useless names like :1 generated by the visual editor itself). Maybe that is the lesser evil?