r17383 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r17382‎ | r17383 | r17384 >
Date:15:34, 3 November 2006
Author:brion
Status:old
Tags:
Comment:
Parser tests for recent change in <ref> behavior, plus fix for failure of that behavior when the first ref is set to exactly "0"
Modified paths:
  • /trunk/extensions/Cite/Cite.php (modified) (history)
  • /trunk/extensions/Cite/citeParserTests.txt (modified) (history)

Diff [purge]

Index: trunk/extensions/Cite/citeParserTests.txt
@@ -136,3 +136,51 @@
137137 <p>1337
138138 </p>
139139 !! end
 140+
 141+!! test
 142+Blank ref followed by ref with content
 143+!! input
 144+<ref name="blank"/>
 145+
 146+<ref name="blank">content</ref>
 147+
 148+<references/>
 149+!! result
 150+<p><sup id="_ref-blank_0" class="reference"><a href="#_note-blank" title="">[1]</a></sup>
 151+</p><p><sup id="_ref-blank_1" class="reference"><a href="#_note-blank" title="">[1]</a></sup>
 152+</p>
 153+<ol class="references"><li id="_note-blank">↑ <a href="#_ref-blank_0" title=""><sup>1.0</sup></a> <a href="#_ref-blank_1" title=""><sup>1.1</sup></a> content</li></ol>
 154+
 155+!! end
 156+
 157+!! test
 158+Regression: non-blank ref "0" followed by ref with content
 159+!! input
 160+<ref name="blank">0</ref>
 161+
 162+<ref name="blank">content</ref>
 163+
 164+<references/>
 165+!! result
 166+<p><sup id="_ref-blank_0" class="reference"><a href="#_note-blank" title="">[1]</a></sup>
 167+</p><p><sup id="_ref-blank_1" class="reference"><a href="#_note-blank" title="">[1]</a></sup>
 168+</p>
 169+<ol class="references"><li id="_note-blank">↑ <a href="#_ref-blank_0" title=""><sup>1.0</sup></a> <a href="#_ref-blank_1" title=""><sup>1.1</sup></a> 0</li></ol>
 170+
 171+!! end
 172+
 173+!! test
 174+Regression sanity check: non-blank ref "1" followed by ref with content
 175+!! input
 176+<ref name="blank">1</ref>
 177+
 178+<ref name="blank">content</ref>
 179+
 180+<references/>
 181+!! result
 182+<p><sup id="_ref-blank_0" class="reference"><a href="#_note-blank" title="">[1]</a></sup>
 183+</p><p><sup id="_ref-blank_1" class="reference"><a href="#_note-blank" title="">[1]</a></sup>
 184+</p>
 185+<ol class="references"><li id="_note-blank">↑ <a href="#_ref-blank_0" title=""><sup>1.0</sup></a> <a href="#_ref-blank_1" title=""><sup>1.1</sup></a> 1</li></ol>
 186+
 187+!! end
Index: trunk/extensions/Cite/Cite.php
@@ -291,7 +291,7 @@
292292 );
293293 } else {
294294 // We've been here before
295 - if ( empty($this->mRefs[$key]['text']) and !empty($str)) {
 295+ if ( $this->mRefs[$key]['text'] === null && $str !== '' ) {
296296 // If no text found before, use this text
297297 $this->mRefs[$key]['text'] = $str;
298298 };