mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-23 22:45:20 +00:00
Add test cases for impossible follow vs. rollback edge case
While working on the patch I4303642 I was worried about the line array_pop( $this->refCallStack ) in the rollback code. Since the patch changed the position of follow elements in the stack, an array_pop() would pop different elements. It turns out this is impossible. Rollbacks are only done for <ref> elements inside a <references> tag, immediatelly after reaching the closing </references>. It's impossible to use follow="…" inside <references>. It will not be added to the stack, and therefore not rolled back. Even if the edge case would be possible, the *old* code that placed follow elements on the *other* side of the stack would have been wrong then. The test cases in this patch try to hit this edge case, and are expected to not be able to do so. Change-Id: I4380bf443db17c6214dbfa2cbda62b46db04258a
This commit is contained in:
parent
d488194c0d
commit
a00b8d990d
|
@ -112,3 +112,49 @@ false or error
|
|||
</li>
|
||||
</ol></div>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
It should be impossible to roll back a follow="…", because it can't have a name
|
||||
!! wikitext
|
||||
<ref name="a" />
|
||||
<ref name="b">should be 2</ref>
|
||||
<references>
|
||||
<ref name="a">should be 1</ref>
|
||||
<ref name="c" follow="other page">is invalid</ref>
|
||||
</references>
|
||||
!! html
|
||||
<p><sup id="cite_ref-a_1-0" class="reference"><a href="#cite_note-a-1">[1]</a></sup>
|
||||
<sup id="cite_ref-b_2-0" class="reference"><a href="#cite_note-b-2">[2]</a></sup>
|
||||
</p>
|
||||
<div class="mw-references-wrap"><ol class="references">
|
||||
<li id="cite_note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">should be 1</span>
|
||||
</li>
|
||||
<li id="cite_note-b-2"><span class="mw-cite-backlink"><a href="#cite_ref-b_2-0">↑</a></span> <span class="reference-text">should be 2</span>
|
||||
</li>
|
||||
</ol></div>
|
||||
<p><span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code><ref></code> tag; invalid names, e.g. too many</span>
|
||||
</p>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
It should be impossible to roll back a follow="…", because it must have a name
|
||||
!! wikitext
|
||||
<ref name="a" />
|
||||
<ref name="b">should be 2</ref>
|
||||
<references>
|
||||
<ref name="a">should be 1</ref>
|
||||
<ref follow="other page">is invalid</ref>
|
||||
</references>
|
||||
!! html
|
||||
<p><sup id="cite_ref-a_1-0" class="reference"><a href="#cite_note-a-1">[1]</a></sup>
|
||||
<sup id="cite_ref-b_2-0" class="reference"><a href="#cite_note-b-2">[2]</a></sup>
|
||||
</p>
|
||||
<div class="mw-references-wrap"><ol class="references">
|
||||
<li id="cite_note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">should be 1</span>
|
||||
</li>
|
||||
<li id="cite_note-b-2"><span class="mw-cite-backlink"><a href="#cite_ref-b_2-0">↑</a></span> <span class="reference-text">should be 2</span>
|
||||
</li>
|
||||
</ol></div>
|
||||
<p><span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: <code><ref></code> tag defined in <code><references></code> has no name attribute.</span>
|
||||
</p>
|
||||
!! end
|
||||
|
|
Loading…
Reference in a new issue