Page MenuHomePhabricator

Visual Editor duplicates the content when reusing (or copy-pasting) newly added citations
Closed, ResolvedPublicBUG REPORT

Description

List of steps to reproduce (step by step, including full links if applicable):
I created a new sandbox to prepare a table of railway stations on a railway line [[User:Kerry Raymond/sandbox5]]

  • I created the right number of columns, put in the headings.
  • I then took a series of maps which cover the length of the railway way, and for each map, add entries for each of the railway stations on the line on that map. After finishing with each map, I then went and cited the first of railway stations from that map by using Cite > Manual > website. I then copied that citation to each of the rows below for the other railway stations that I had added to the table from that map. Then I repeated the process for each of the other maps

What happens?:
The result of doing this is https://en.wikipedia.org/w/index.php?title=User:Kerry_Raymond/sandbox5&diff=prev&oldid=1066407160 which looks fine in Read Mode, 6 citations at the bottom. But then I noticed I had forgotten some of the fields in citation [6] so I went back in to add them and went to the edit the [6] in the bottom row of the table. And I could not do it. It shows "<> ref" with an Edit button that took me an empty text box. Same with other citations. The only one of the numerous [6] citations I could edit was the original one on the row with Gihibi as the station name. So I went into source mode and found that the copying of the map citations were all repeated in full, rather than all-but-one being reuse of an existing citation

What should have happened instead?:

I would have expected citation re-use to have occurred when copying and pasting a citation within the article.

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc.:

Event Timeline

ppelberg moved this task from To Triage to Triaged on the VisualEditor board.
ppelberg moved this task from Untriaged to Upcoming on the Editing-team board.

Thanks for the detailed report. To summarize, I see two different issues here:

  1. A visual editor edit generated wikitext like this, which is incorrect – the reference theodore is defined twice with different contents:
|-
|{{convert|142|mi|50|chain}}
|[[Kaloola railway station|Kaloola]]
|{{Coord|-24.8487|150.0624|type:railwaystation_region:AU-QLD|name=Kaloola railway station (former)}}
|{{convert|531|ft}}
|<ref name="railwaystations" /><ref name="theodore">{{Cite web|date=1972|title=Theodore|url=https://gisservices.information.qld.gov.au/arcgis/rest/directories/historicalscans/cad_scans/cad-map-100000-8948-theodore-admin-bdy-1972.jpg|url-status=live|access-date=18 January 2022|publisher=[[Queensland Government]]|type=Map}}</ref>
|-
|{{convert|146|mi|72|chain}}
|[[Goolara railway station|Goolara]]
|
|{{convert|461|ft}}
|<ref name="theodore" />
|-
|{{convert|149|mi|72|chain}}
|[[Theodore railway station, Queensland|Theodore]]
|{{coord|-24.9491|150.0820|tyoe:railwaystation_region:AU-QLD|name=Theodore railway station}}
|{{convert|461|ft}}
|<ref name="theodore">{{Cite web|date=1972|title=8948 Theodore|url=https://gisservices.information.qld.gov.au/arcgis/rest/directories/historicalscans/cad_scans/cad-map-100000-8948-theodore-admin-bdy-1972.jpg|url-status=live|publisher=[[Queensland Government]]|type=Map}}</ref>
|}
  1. When you load that page in the visual editor again, the second definition of the reference behaves strangely:

image.png (2×3 px, 478 KB)

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

[mediawiki/extensions/Cite@master] ve-cite: Handle ref nodes with mw:Error RDFa

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

Change 755739 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] ve-cite: Handle ref nodes with mw:Error RDFa

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

If you are looking at the current version of my sandbox5, then it's been fixed manually (or so I thought, I obviously missed the 2nd theodore reference). I had to as this is actual content I am working on so I had to fix it; it wasn't just some kind of test. If you look at [https://en.wikipedia.org/w/index.php?title=User:Kerry_Raymond/sandbox5&oldid=1066408215 this version], you will see dozens of repeated citations instead of extensive re-use of a number of them

@Kerry_Raymond Thanks for pointing it out, indeed I was looking at the latest version. I followed the link you gave: [https://en.wikipedia.org/w/index.php?title=User:Kerry_Raymond/sandbox5&diff=prev&oldid=1066407160] and I didn't notice that Phabricator includes the ] at the end in the link URL, which causes MediaWiki to show the latest version instead of the one you meant to link to.

I was also confused by the phrase "not reusing" – I understood that to mean that you copied the reference in a scenario like this:

image.png (217×561 px, 2 KB)

…and ended up with this:

image.png (217×561 px, 3 KB)

…instead of this:

image.png (217×561 px, 2 KB)

…but of course that's not what you meant, and not what happened. I'll change the task title to clarify.

matmarex renamed this task from Visual Editor not reusing citations when copying and pasting them to Visual Editor duplicates the content in reused citations when copying and pasting them.Jan 22 2022, 1:45 AM

Now that I know what I'm doing, I can easily reproduce this: https://en.wikipedia.beta.wmflabs.org/wiki/T299378

Further notes:

  • The table isn't required to trigger this, refereces in plain text are affected too
  • Only references inserted in the same edit trigger the issue – copy-pasting references that were already on the page works fine
  • Using Cite → Re-use instead of copy-pasting also triggers the issue

That's interesting. My impression was that Cite Reuse seemed to be working ok. But I had not noticed that "Only references inserted in the same edit trigger the issue", so it may be that I was only observing Cite Reuse in the context of reusing a reference being created in a previous edit.

I think this bug is fairly recent (within the last week or so). I had noticed on my watchlist that others were editing articles I had worked on and were replacing duplicate citations with citation reuse. The first few times I saw this, I just thought, "silly me, I must have added that citation twice". But when it happened a few more times and I started thinking "how on earth can I be doing it so much, and just in the past few days, what I am I doing differently to my usual editing style?". It was only when I saw it happen on a massive scale in my sandbox5 which I had just finished editing and had done so in a very formulaic way that I noticed that the duplicate citations had the same VE-generated names, e.g. <ref name=":01"> and I was not re-entering the citation multiple times as VE would have named them differently even if the content was the same. That was the "there's a bug" moment.

matmarex renamed this task from Visual Editor duplicates the content in reused citations when copying and pasting them to Visual Editor duplicates the content when reusing (or copy-pasting) newly added citations.Jan 24 2022, 10:32 PM

Change 757553 had a related patch set uploaded (by Esanders; author: Esanders):

[mediawiki/extensions/Cite@master] ve-cite: Ensure references are always unique by generating originalDomElementsHash

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

Change 757553 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] ve-cite: Ensure references are always unique by generating originalDomElementsHash

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

I have checked to confirm that Visual Editor does not duplicate content when reusing/copy-pasting newly added citations.

See https://photos.app.goo.gl/y6qk9zW4f3S74jvU7 to confirm that it acts as expected.

ppelberg claimed this task.
ppelberg subscribed.

@Kerry_Raymond we think the issue you were experiencing now resolved. Can you please boldly re-open this task if you are still experience the issue?