Page MenuHomePhabricator

Main ref lost when pasting a sub-ref into articles with existing sub-refs (M)
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue
  • Start with two pages with the following Wikitext
<ref name="book" details="page 1">Miller</ref>

And

<ref name="other" details="chapter 1">Smith</ref>
  • Open the pages in VE in different tabs
  • Copy the Miller sub-ref from one tab into the other
  • Preview the Wikitext changes
What happens?:
  • The sub-ref will be added as [1.2]
  • In the reflist it's a sub-ref of the Smith main ref
  • The main ref Miller is not copied over and lost
  • Wikitext of the sub-ref is <ref name="book" details="page 1" />
What should have happened instead?:
  • The sub-ref will be added as [2.1]
  • You see a new main ref with Miller having a sub-ref with page 1
  • Wikitext of the sub-ref is <ref name="book" details="page 1">Miller</ref>
Solution

When new ReferenceNodes are copied into an existing document with existing ReferenceNodes we also need to make sure that the listIndex do not collide. The new content will be added to the end of the InternalList and the indexes on the new nodes need to be updated.

On part where this is happening is ve.dm.MWReferenceNode.static.remapInternalListIndexes it takes an listIndexMap as input. This map is created from the InternalList that has a method that takes care when two documents ( meaning also two InternalLists ) are merged. See ve.dm.InternalList.prototype.merge

We probably only have to make sure that remapInternalListIndexes also remaps the mainListIndex the merge method should already be fine.

Tests

We should add at least two test to ve.ce.ClipboardHandler.test.js where a sub-ref is inserted into a document with sub-ref or with main ref.

Event Timeline

MareikeHeuerWMDE renamed this task from Main ref lost when pasting a sub-ref into articles with existing sub-refs to Main ref lost when pasting a sub-ref into articles with existing sub-refs (M).Aug 31 2026, 10:01 AM

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

[mediawiki/extensions/Cite@master] QUnit: Adding sub-ref case to the ClipboardHandler tests

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

Change #1335782 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] QUnit: Adding sub-ref case to the ClipboardHandler tests

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