Page MenuHomePhabricator

Bad numbering when reusing a sub-reference before it's defined
Closed, ResolvedPublic5 Estimated Story Points

Description

This situation currently results in bad rendering:

<ref name="a">Book</ref>
<ref name="b" />
<ref name="b" extends="a">Page 2</ref>

The functionality is pretty much fine, but the visible numbers are bad. The first appearance of name="b" is rendered as [2] instead of [1.1]. There is currently no easy way to resolve this. This is basically just like the Cite extension works: Parsing is done from top to bottom. The first time a <ref> appears, it gets a number. This is fine for top-level references. But the <ref name="b" /> is meant to be a sub-reference. This only becomes obvious later in the process.

The least minimal thing we need to do before deploying the feature anywhere is reporting this situation with an error message, e.g. "Can not change a non-extended <ref> to an extended one".

Event Timeline

Change 565276 had a related patch set uploaded (by Awight; owner: Awight):
[mediawiki/extensions/Cite@master] [WIP] Error when reusing a ref with mixed "extends"

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

awight moved this task from Doing to Sprint Backlog on the WMDE-QWERTY-Sprint-2020-01-08 board.
thiemowmde moved this task from Doing to Review on the WMDE-QWERTY-Sprint-2020-01-08 board.

Change 565276 merged by jenkins-bot:
[mediawiki/extensions/Cite@master] Error when reusing <ref> with conflicting "extends" attributes

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

Manually confirmed on https://de.wikipedia.beta.wmflabs.org with the example provided above.

Change 566737 had a related patch set uploaded (by Thiemo Kreuz (WMDE); owner: Thiemo Kreuz (WMDE)):
[mediawiki/extensions/Cite@master] Introduce dedicated error message for nested <ref extends=…>

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

Change 566737 merged by jenkins-bot:
[mediawiki/extensions/Cite@master] Introduce dedicated error message for nested <ref extends=…>

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