Fix incomplete rollback producing bad footnote numbers

Bug: T48140
Change-Id: I53ce5d8488d4c24d6f23f6f0e70806d7db4064e1
This commit is contained in:
Thiemo Kreuz 2020-01-24 13:02:53 +01:00
parent 6ad54f0d63
commit 2ddc6f133b
2 changed files with 28 additions and 1 deletions

View file

@ -340,10 +340,12 @@ class ReferenceStack {
case 'new':
// Rollback the addition of new elements to the stack
unset( $this->refs[$group][$lookup] );
// TODO: Don't we need to rollback groupRefSequence and extendsCount as well?
if ( !$this->refs[$group] ) {
$this->popGroup( $group );
} elseif ( isset( $this->groupRefSequence[$group] ) ) {
$this->groupRefSequence[$group]--;
}
// TODO: Don't we need to rollback extendsCount as well?
break;
case 'new-from-placeholder':
$this->refs[$group][$lookup]['__placeholder__'] = true;

View file

@ -2037,6 +2037,31 @@ T242437 - Blank ref name in #tag regression
</p>
!! end
!! test
T48140 - Make sure rollback/redo does not consume numbers
!! wikitext
<ref>should be [1]</ref>
<ref name="a" group="g" />
{{#tag:references|
<ref name="a">a</ref>
|group=g}}
<ref>should be [2]</ref>
!! html
<p><sup id="cite_ref-1" class="reference"><a href="#cite_note-1">&#91;1&#93;</a></sup>
<sup id="cite_ref-a_2-0" class="reference"><a href="#cite_note-a-2">&#91;g 1&#93;</a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-a-2"><span class="mw-cite-backlink"><a href="#cite_ref-a_2-0">↑</a></span> <span class="reference-text">a</span>
</li>
</ol></div>
<sup id="cite_ref-4" class="reference"><a href="#cite_note-4">&#91;2&#93;</a></sup><div class="mw-references-wrap"><ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">should be [1]</span>
</li>
<li id="cite_note-4"><span class="mw-cite-backlink"><a href="#cite_ref-4">↑</a></span> <span class="reference-text">should be [2]</span>
</li>
</ol></div>
!! end
!! test
Numbers in the default group need to start with 1, independent from other groups
!! wikitext