User story:
As a VE user,
when I delete a main reference
then any sub-references associated with it should not be orphaned
so that the citations do not break, become confusing for readers and editors.
Acceptance criteria:
GIVEN [1] [1.1] in VE, wikitext:
<ref name="book">Miller 2025</ref> <ref name="book" details="page 1" />
WHEN deleting [1] in VE (line 1 in wikitext)
THEN [1.1] should stay intact
AND [1.1] should still be able to refer to the main content in the context menu
AND the reference list should not change, it should continue to show the main reference after "1."
AND saving will result in the following wikitext:~~ (removed from scope)
<ref name="book" details="page 1" >Miller 2025</ref>
Dev notes
- As long as there's a synthetic main ref in the references list we can show the content to the users in VE and merge it back to Wikitext.
- We can move a reference node from the article to the references list as shown in https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Cite/+/1154055
Current status
Currently the main issue here is, that there's no node that could provided the main content left and we're exploring how we could solve that. If weThe three options are
A) Move the main node during deletion to the references list as synthetic main ref
- It seems hard to find the right trigger for that move. The obvious on would the detach but that is messy due to the transaction that's executed makeing that call. See https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Cite/+/1178481
B) Make sure the content of the main body can be restored from and accessed via the InternalList even if the last main node got deleted from the document.
- When the node is removed from the document, the content can sill be found in the InternalList in an InternalListNode.
- Currently the InternalListNode cannot clearly be mapped to a subref that needs it - see T401313: Investigate whether InternalItemNodes can be used to recreate content of deleted nodes
- The InternalListNode might also need to store additional attributes form the original main ref so that it can be converted back to a synthethic main ref - see T401329: Discuss whats missing in InteralList/InternalItemNode to retrieve delete ReferenceNode's content
- We're a bit unsure of the future of the InternalList though and it might be a long term approach to resolve the dependencies present there.
C) Make sure that there's always a ( even redundant ) synthetic main ref if there's a subref
- We're tending towards this solution. It introduces some technical debt but we're not too confident anymore putting more info into the InternalList - see T401887: Spike: Create a (redundant) synthetic ref when details is used