Page MenuHomePhabricator

VE: Deleting sub-ref attached to main content does not orphan other sub-refs in same article
Closed, ResolvedPublic

Description

User story:

As a VE user,
when I delete a sub-reference (that contains the main content)
and there is at least one other sub-reference for the same main content in the article,
then the main reference content should be preserved
so that valuable citation data is not accidentally lost and the remaining references continue to function.

Acceptance criteria:

GIVEN: two sub-references: [1.1] [1.2] with the following wikitext:

<ref name="book" details="page 1">Miller 2025</ref>
<ref name="book" details="page 2"/>

WHEN I delete [1.1] (line 1 in wikitext: the sub-ref that is containing the main ref data)
THEN the content of the main ref is still available in the context item for "[1.1]" and in the references list under "1."
AND when saving to wikitext, the main ref is moved into line 2 (the nearest one in the document). Resulting wikitext:

<ref name="book" details="page 2">Miller 2025</ref>

Out of scope

  • Saving back to wikitext is currently broken and will be fixed in a separate task.

Boundaries:

  • If only a reuse of the main reference exists and no other sub-references then it is fine for now that VE moves the main content to a new ref tag in the references list. This will change at a later stage.
    image.png (408×1 px, 41 KB)
  • Do not move into infobox or other templates.

Link to internal board:

Technical notes:

  • This logic already exists for normal refs, look for how the contentsUsed flag is set and maintained.

Related Objects

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
WMDE-Fisch renamed this task from Deleting references in does not orphan subrefs to VE: Deleting references in does not orphan subrefs.Apr 9 2025, 8:01 PM
Lina_Farid_WMDE renamed this task from VE: Deleting references in does not orphan subrefs to VE: Deleting sub-ref attached to main content does not orphan other sub-refs in same article.Apr 16 2025, 3:29 PM
Lina_Farid_WMDE updated the task description. (Show Details)

Note the current behavior is the same for both these examples:

<ref name="book" details="page 1">Miller 2025</ref>
<ref name="book" details="page 2" />
<ref name="book" details="page 1">Miller 2025</ref>
<ref name="book" />

In both cases, when I delete the 1st ref the content currently doesn't move to the 2nd ref (expected behavior) but into the reflist (current behavior). This ticket will probably fix both cases. Update: Fixed.

The behavior is also the same when I delete both refs. The result is that the artificial list-defined main reference is left behind with no usage anywhere.

<references>
<ref name="book">Miller 2025</ref>
</references>

This is pretty much the exact same situation as above, just that there is no other sub-ref left at the end. The main ref should be completely removed then.

thiemowmde raised the priority of this task from High to Needs Triage.May 14 2025, 7:20 AM

Change #1176756 had a related patch set uploaded (by WMDE-Fisch; author: WMDE-Fisch):

[mediawiki/extensions/Cite@master] Move the main body content to the subref if needed

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

Change #1176758 had a related patch set uploaded (by WMDE-Fisch; author: WMDE-Fisch):

[mediawiki/extensions/Cite@master] Converter: Adding test for moving main content from a subref

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

Change #1176758 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Converter: Adding test for moving main content from a subref

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

Change #1177360 had a related patch set uploaded (by WMDE-Fisch; author: WMDE-Fisch):

[mediawiki/extensions/Cite@master] Save synthetic main body content on other refs

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

Change #1177361 had a related patch set uploaded (by WMDE-Fisch; author: WMDE-Fisch):

[mediawiki/extensions/Cite@master] Converter tests: Adding another test for subrefs losing main

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

Change #1177361 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Converter tests: Adding another test for subrefs losing main

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

Change #1177996 had a related patch set uploaded (by WMDE-Fisch; author: WMDE-Fisch):

[mediawiki/extensions/Cite@master] Save synthetic main body content on another subref if needed

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

Change #1176756 abandoned by WMDE-Fisch:

[mediawiki/extensions/Cite@master] Move the main body content to the subref if needed

Reason:

Split into I02f590d5e7b102b63e60362f32f7952c6300e6b5 and I389dc7465dc80bd17cd78cd8cc432ec8c5a82e5c

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

Change #1179117 had a related patch set uploaded (by Awight; author: Awight):

[VisualEditor/VisualEditor@master] Test ve.dm.InternalList#getItemInsertion

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

Change #1179129 had a related patch set uploaded (by Awight; author: Awight):

[mediawiki/extensions/Cite@master] Extract general tests on ve.dm.InternalList

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

Change #1179137 had a related patch set uploaded (by Awight; author: Awight):

[mediawiki/extensions/Cite@master] [WIP] Stubs where we would need to handle main refs

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

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

[mediawiki/extensions/Cite@master] Code cleanups in MWReferenceNode and related

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

Change #1177360 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Save synthetic main body content on other refs

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

Change #1177996 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Save synthetic main body content on another subref if needed

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

Note that our fix currently only works for the case where the document was loaded from Parsoid. If the main & main+details are created in VE, then the synthetic LDR is never created and deleting the main ref will orphan the subref.

However, proof-of-concept code in https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Cite/+/1178850 will patch this hole.

Change #1178850 had a related patch set uploaded (by Awight; author: WMDE-Fisch):

[mediawiki/extensions/Cite@master] [WIP] Always create synthetic main ref when adding details

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

Change #1179117 merged by jenkins-bot:

[VisualEditor/VisualEditor@master] Move InternalList tests from Cite

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

Change #1178850 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Always create synthetic main ref when adding details

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

Change #1184623 had a related patch set uploaded (by Jforrester; author: Jforrester):

[mediawiki/extensions/VisualEditor@master] Update VE core submodule to master (4f51b5f65)

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

Change #1184623 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Update VE core submodule to master (4f51b5f65)

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

Change #1179144 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Code cleanups in MWReferenceNode and related

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

Change #1185982 had a related patch set uploaded (by DLynch; author: DLynch):

[mediawiki/extensions/VisualEditor@wmf/1.45.0-wmf.17] Update VE core submodule to master (a5bd08c8b)

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

Change #1185982 abandoned by DLynch:

[mediawiki/extensions/VisualEditor@wmf/1.45.0-wmf.17] Update VE core submodule to master (a5bd08c8b)

Reason:

Would need to do the subrepo backport anyway

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

Change #1185982 restored by DLynch:

[mediawiki/extensions/VisualEditor@wmf/1.45.0-wmf.17] Update VE core submodule to master (a5bd08c8b)

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

Change #1185982 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@wmf/1.45.0-wmf.17] Update VE core submodule to master (a5bd08c8b)

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

Mentioned in SAL (#wikimedia-operations) [2025-09-08T20:11:02Z] <kemayo@deploy1003> kemayo, esanders: Backport for [[gerrit:1185991|Enable DT thanks at mediawikiwiki (T400849)]], [[gerrit:1185982|Update VE core submodule to master (a5bd08c8b) (T302413 T391521 T397145 T401890 T402392 T397518 T402717 T403741 T403745)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2025-09-08T20:17:50Z] <kemayo@deploy1003> Finished scap sync-world: Backport for [[gerrit:1185991|Enable DT thanks at mediawikiwiki (T400849)]], [[gerrit:1185982|Update VE core submodule to master (a5bd08c8b) (T302413 T391521 T397145 T401890 T402392 T397518 T402717 T403741 T403745)]] (duration: 13m 05s)