Page MenuHomePhabricator

Document and fix bogus, inconsistent sub-ref behavior inside {{#tag:references}}
Closed, ResolvedPublicBUG REPORT

Description

When a <ref> tag is wrapped in a {{#tag:references|…}} parser function the parsing of the outer reference list is delayed. The inner <ref> tag is parsed first without knowing the outer context of the reference list. This is internally un-done (via a so called "rollback stack") and re-done, this time with the correct context.

This is how {{reflist}} works.

The problem is that a sub-reference possibly (not always) creates two new items in the internal data structures. But there is no code that can ever roll back more than one. This causes various glitches. For example:

  • Either the main ref or the sub-ref will be marked as being used twice (visible via the "↑ a b" backlinks), even if they are never re-used.
  • Only the sub-ref is rolled back and re-done, but the main ref is not. The main ref will show a behavior that doesn't make sense for a list-defined ref.
  • A previous, technically unrelated ref is not rolled back correctly and shows a behavior that doesn't make sense for a list-defined ref.
  • Numbers are consumed twice, creating gaps and mismatches between footnote markers and reference list.

This is an actual flaw in the current implementation (for the legacy parser). It's an edge-case we will probably not run into during user testing and such. But it should definitely block any larger deployment. We know that communities like enwiki where {{reflist}} is used will definitely run into this.

First steps:

  • Add parser test cases that use both {{#tag:references|…}} as well as {{#tag:ref|…}} in various combinations.
  • Make sure to cover especially situations where the rollback/redo logic from the old parser implementation kicks in. This happens especially when normal <ref> are wrapped inside {{#tag:references|…}}.
  • Identify issues related to the fact that one sub-ref can actually create two entries in the internal data structures.

Event Timeline

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

[mediawiki/extensions/Cite@master] Remove not needed extra rollback stack entry

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

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

[mediawiki/extensions/Cite@master] [POC] Fix rollback logic to roll back main and sub-ref

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

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

[mediawiki/extensions/Cite@master] Add test cases documenting inconsistent rollback behavior

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

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

[mediawiki/extensions/Cite@master] Fix Phan/PHPDocs for the internal rollback stack

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

Change #1125376 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Fix Phan/PHPDocs for the internal rollback stack

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

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

[mediawiki/extensions/Cite@master] Fix unused sub-ref parent sometimes getting a backlink

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

Change #1125292 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Add test cases documenting inconsistent rollback behavior

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

Change #1127055 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Fix unused sub-ref parent sometimes getting a backlink

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

Change #1125170 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Remove not needed extra rollback stack entry

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

thiemowmde renamed this task from Document and fix <ref details> behavior inside {{#tag:references}} to Document and fix bogus, inconsistent sub-ref behavior inside {{#tag:references}}.Mar 19 2025, 9:25 AM
thiemowmde removed thiemowmde as the assignee of this task.
thiemowmde updated the task description. (Show Details)
thiemowmde added a subscriber: Lina_Farid_WMDE.

Change #1123695 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Fix rollback logic to roll back main and sub-ref

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

thiemowmde moved this task from Demo to Done on the WMDE-TechWish-Sprint-2025-04-16 board.