mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-09-24 10:48:58 +00:00
Fix incomplete undo/redo stack implementation
The rollback feature was not able to properly restore a __placeholder__. That's why a specific use case was behaving different. This already worked just fine: <ref extends="a">…</ref> <references> <ref name="a">…</ref> </references> But this didn't, even if it is the exact same from the users perspective: <ref extends="a">…</ref> {{#tag:references| <ref name="a">…</ref> }} Bug: T239810 Change-Id: I163a1bffb9450a9e7f776e32e66fb08d0452cdb9
This commit is contained in:
parent
70e53556a4
commit
d07110b790
|
@ -181,7 +181,7 @@ class ReferenceStack {
|
|||
unset( $ref['number'] );
|
||||
$ref = array_merge( $ref, $this->refs[$group][$name] );
|
||||
$this->refs[$group][$name] =& $ref;
|
||||
$action = 'new';
|
||||
$action = 'new-from-placeholder';
|
||||
} elseif ( !isset( $this->refs[$group][$name] ) ) {
|
||||
// Valid key with first occurrence
|
||||
$this->refs[$group][$name] = &$ref;
|
||||
|
@ -346,6 +346,10 @@ class ReferenceStack {
|
|||
}
|
||||
// TODO: else, don't we need to decrement groupRefSequence?
|
||||
break;
|
||||
case 'new-from-placeholder':
|
||||
$this->refs[$group][$lookup]['__placeholder__'] = true;
|
||||
unset( $this->refs[$group][$lookup]['count'] );
|
||||
break;
|
||||
case 'assign':
|
||||
# Rollback assignment of text to pre-existing elements.
|
||||
$this->refs[$group][$lookup]['text'] = null;
|
||||
|
|
|
@ -570,7 +570,6 @@ wgCiteBookReferencing=true
|
|||
</ol></div>
|
||||
!! end
|
||||
|
||||
# TODO: Should behave the same as above!
|
||||
!! test
|
||||
T239810: Extending a <ref> that doesn't appear in the text, but in {{#tag:references}}
|
||||
!! config
|
||||
|
@ -584,11 +583,11 @@ wgCiteBookReferencing=true
|
|||
<p><sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1.1]</a></sup>
|
||||
</p>
|
||||
<div class="mw-references-wrap"><ol class="references">
|
||||
<li id="cite_note-a-2"><span class="mw-cite-backlink">↑ </span> <span class="reference-text">Book</span>
|
||||
<ol class="mw-extended-references"><li id="cite_note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">Page 2</span>
|
||||
</li>
|
||||
</ol></ol></div>
|
||||
<p><span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: <code><ref></code> tag with name "a" defined in <code><references></code> is not used in prior text.</span>
|
||||
</p>
|
||||
</ol></li>
|
||||
</ol></div>
|
||||
!! end
|
||||
|
||||
# TODO: This should be invalid, there's no way to know that `footwo` should be subnumbered in a one-pass parse.
|
||||
|
@ -622,7 +621,6 @@ wgCiteBookReferencing=true
|
|||
<ref>BAR</ref>
|
||||
<ref name="footwo" extends="foo">page 7</ref>
|
||||
<ref name="foo" />
|
||||
|
||||
{{#tag:references|
|
||||
<ref name="foo">book name</ref>
|
||||
}}
|
||||
|
|
|
@ -502,7 +502,7 @@ class ReferenceStackTest extends \MediaWikiUnitTestCase {
|
|||
],
|
||||
[
|
||||
[ 'new', 1, 'foo', 'a', 'b', 'text-a', [] ],
|
||||
[ 'new', 2, 'foo', 'b', null, 'text-b', [] ],
|
||||
[ 'new-from-placeholder', 2, 'foo', 'b', null, 'text-b', [] ],
|
||||
]
|
||||
],
|
||||
'Named extends after parent' => [
|
||||
|
@ -644,7 +644,7 @@ class ReferenceStackTest extends \MediaWikiUnitTestCase {
|
|||
],
|
||||
[
|
||||
[ 'new', 1, 'foo', null, 'b', 'text-a', [] ],
|
||||
[ 'new', 2, 'foo', 'b', null, 'text-b', [] ],
|
||||
[ 'new-from-placeholder', 2, 'foo', 'b', null, 'text-b', [] ],
|
||||
]
|
||||
],
|
||||
'Anonymous extends after parent' => [
|
||||
|
|
Loading…
Reference in a new issue