mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-24 06:54:00 +00:00
Block de-facto empty <ref> as if it's empty
The use case we care about is this: <ref extends="some_book"> </ref> It doesn't make sense that works, but the following doesn't: <ref extends="some_book"></ref> We decided that both need to behave the same. For consistency this patch is applying the same change to all references, no matter if they use the extends attribute or not. This is an actual change and might make existing wikitext render differently. However, I would like to argue that all wikitext that was using this was broken. The effect of a <ref> </ref> with some whitespace is that the <references> section at the end of the article will contain – well – an empty footnote. Bug: T237241 Change-Id: Iaee35583eabcb416b0a06849b89ebbfb0fb7fef9
This commit is contained in:
parent
8e800a8988
commit
b10dd4ec27
|
@ -256,7 +256,8 @@ class Cite {
|
|||
return '';
|
||||
}
|
||||
|
||||
if ( $text === '' ) {
|
||||
// @phan-suppress-next-line PhanImpossibleTypeComparison false positive
|
||||
if ( $text !== null && trim( $text ) === '' ) {
|
||||
# <ref ...></ref>. This construct is invalid if
|
||||
# it's a contentful ref, but OK if it's a named duplicate and should
|
||||
# be equivalent <ref ... />, for compatability with #tag.
|
||||
|
@ -862,7 +863,7 @@ class Cite {
|
|||
* @return string
|
||||
*/
|
||||
private function referenceText( $key, $text ) {
|
||||
if ( $text === null || $text === '' ) {
|
||||
if ( trim( $text ) === '' ) {
|
||||
if ( $this->mParser->getOptions()->getIsSectionPreview() ) {
|
||||
return $this->errorReporter->wikitext( 'cite_warning_sectionpreview_no_text', $key );
|
||||
}
|
||||
|
|
|
@ -254,12 +254,11 @@ wgCiteBookReferencing=true
|
|||
<ref extends="foo"> </ref>
|
||||
!! html/php
|
||||
<p><sup id="cite_ref-foo_1-0" class="reference"><a href="#cite_note-foo-1">[1]</a></sup>
|
||||
<span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code><ref></code> tag;
|
||||
</p>
|
||||
<sup id="cite_ref-2" class="reference"><a href="#cite_note-2">[2]</a></sup><div class="mw-references-wrap"><ol class="references">
|
||||
refs with no name must have content</span><div class="mw-references-wrap"><ol class="references">
|
||||
<li id="cite_note-foo-1"><span class="mw-cite-backlink"><a href="#cite_ref-foo_1-0">↑</a></span> <span class="reference-text">book</span>
|
||||
</li>
|
||||
<li id="cite_note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text"> </span>
|
||||
</li>
|
||||
</ol></div>
|
||||
!! end
|
||||
|
||||
|
|
|
@ -547,7 +547,7 @@ refs with no name must have content</span>
|
|||
!! test
|
||||
<ref> with an empty-string name parameter and no content.
|
||||
!! wikitext
|
||||
Bla.<ref name=""></ref>
|
||||
Bla.<ref name=""> </ref>
|
||||
!! html
|
||||
<p>Bla.<span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code><ref></code> tag;
|
||||
refs with no name must have content</span>
|
||||
|
@ -557,7 +557,7 @@ refs with no name must have content</span>
|
|||
!! test
|
||||
<ref> with a non-empty name parameter and no content.
|
||||
!! wikitext
|
||||
Bla.<ref name="void"></ref>
|
||||
Bla.<ref name="void"> </ref>
|
||||
!! html
|
||||
Bla.<sup id="cite_ref-void_1-0" class="reference"><a href="#cite_note-void-1">[1]</a></sup><div class="mw-references-wrap"><ol class="references">
|
||||
<li id="cite_note-void-1"><span class="mw-cite-backlink"><a href="#cite_ref-void_1-0">↑</a></span> <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code><ref></code> tag;
|
||||
|
|
Loading…
Reference in a new issue