mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-09-23 18:29:15 +00:00
Give a different error from too_many_keys when 'follow' attribute conflicts
Add message "cite_error_ref_follow_conflicts" for tags with conflicting parameters. Bug: T299280 Change-Id: Ie64f4ab4831966f66f812ea67cc244718f818afb
This commit is contained in:
parent
4377f0923d
commit
f7a181ed42
|
@ -21,6 +21,7 @@
|
|||
"cite_error_ref_numeric_key": "Invalid <code><ref></code> tag; name cannot be a simple integer. Use a descriptive title",
|
||||
"cite_error_ref_no_key": "The opening <code><ref></code> tag is malformed or has a bad name",
|
||||
"cite_error_ref_too_many_keys": "Invalid parameter in <code><ref></code> tag",
|
||||
"cite_error_ref_follow_conflicts": "A <code><ref follow=\"…\"></code> tag that is the continuation of a previous one can neither be named individually nor extended",
|
||||
"cite_error_ref_nested_extends": "Extending <code><ref></code> tags more than one level deep is not allowed",
|
||||
"cite_error_ref_no_input": "Invalid <code><ref></code> tag; refs with no name must have content",
|
||||
"cite_error_references_duplicate_key": "Invalid <code><ref></code> tag; name \"$1\" defined multiple times with different content",
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
"cite_error_ref_numeric_key": "Error message shown if the name of a ref tag only contains digits. Examples that cause this error are <code><ref name=\"123\"/></code> or <code><ref name=\"456\">input</ref></code>",
|
||||
"cite_error_ref_no_key": "Error message shown when ref tags without any content (that is <code><ref/></code>) are used without a name.",
|
||||
"cite_error_ref_too_many_keys": "Generic error message shown when unknown, unsupported parameters are used in a <code><ref></code> tag. This can happen when there is a mistake in a parameter name, or a parameter exclusive to the <code><references></code> tag is used in a <code><ref></code> tag. This and [[MediaWiki:Cite error references invalid parameters]] form a pair and should be worded similarly.",
|
||||
"cite_error_ref_follow_conflicts": "Error message shown when a ref tag with the Wikisource-specific <code>follow=\"…\"</code> feature also tries to use a <code>name=\"…\"</code> and/or <code>extends=\"…\"</code> parameter.",
|
||||
"cite_error_ref_nested_extends": "Error message shown when a ref tag tries to extend another ref tag that's already extended, i.e. nesting sub-refs is not allowed.\n\nParameters:\n* $1 - Name of the invalid ref\n* $2 - Name of the previous, conflicting ref",
|
||||
"cite_error_ref_no_input": "Error message shown when ref tags without names have no content. An example that cause this error is <code><ref></ref></code>",
|
||||
"cite_error_references_duplicate_key": "Error message shown when multiple refs with same name exist but with different content",
|
||||
|
|
|
@ -64,8 +64,7 @@ class Validator {
|
|||
}
|
||||
|
||||
if ( $follow && ( $name || $extends ) ) {
|
||||
// TODO: Introduce a specific error for this case.
|
||||
return StatusValue::newFatal( 'cite_error_ref_too_many_keys' );
|
||||
return StatusValue::newFatal( 'cite_error_ref_follow_conflicts' );
|
||||
}
|
||||
|
||||
if ( $dir !== null && !in_array( strtolower( $dir ), [ 'ltr', 'rtl' ], true ) ) {
|
||||
|
|
|
@ -495,7 +495,7 @@ wgCiteBookReferencing=true
|
|||
<references />
|
||||
!! html/php
|
||||
<p><sup id="cite_ref-a_1-0" class="reference"><a href="#cite_note-a-1">[1]</a></sup>
|
||||
<span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid parameter in <code><ref></code> tag</span>
|
||||
<span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: A <code><ref follow="…"></code> tag that is the continuation of a previous one can neither be named individually nor extended</span>
|
||||
</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">book 1</span>
|
||||
|
@ -515,7 +515,7 @@ wgCiteBookReferencing=true
|
|||
!! html/php
|
||||
<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>
|
||||
<span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid parameter in <code><ref></code> tag</span>
|
||||
<span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: A <code><ref follow="…"></code> tag that is the continuation of a previous one can neither be named individually nor extended</span>
|
||||
</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">book 1</span>
|
||||
|
|
|
@ -526,7 +526,7 @@ Can't have name="…" and follow="…" the same time
|
|||
<ref name="theName" follow="theFollows">theValue</ref>
|
||||
<references />
|
||||
!! html/php
|
||||
<p><span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid parameter in <code><ref></code> tag</span>
|
||||
<p><span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: A <code><ref follow="…"></code> tag that is the continuation of a previous one can neither be named individually nor extended</span>
|
||||
</p>
|
||||
!! html/parsoid
|
||||
<p><sup about="#mwt2" class="mw-ref reference" id="cite_ref-theName_1-0" rel="dc:references" typeof="mw:Extension/ref mw:Error" data-mw='{"name":"ref","attrs":{"name":"theName","follow":"theFollows"},"body":{"id":"mw-reference-text-cite_note-theName-1"},"errors":[{"key":"cite_error_ref_too_many_keys"}]}'><a href="./Parser_test#cite_note-theName-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup></p>
|
||||
|
|
|
@ -118,7 +118,7 @@ It should be impossible to roll back a follow="…", because it can't have a nam
|
|||
<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 parameter in <code><ref></code> tag</span>
|
||||
<p><span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: A <code><ref follow="…"></code> tag that is the continuation of a previous one can neither be named individually nor extended</span>
|
||||
</p>
|
||||
!! end
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ class ValidatorTest extends \MediaWikiIntegrationTestCase {
|
|||
'extends' => null,
|
||||
'follow' => 'f',
|
||||
'dir' => null,
|
||||
'expected' => 'cite_error_ref_too_many_keys',
|
||||
'expected' => 'cite_error_ref_follow_conflicts',
|
||||
],
|
||||
'Follow with extends' => [
|
||||
'referencesStack' => [],
|
||||
|
@ -103,7 +103,7 @@ class ValidatorTest extends \MediaWikiIntegrationTestCase {
|
|||
'extends' => 'e',
|
||||
'follow' => 'f',
|
||||
'dir' => null,
|
||||
'expected' => 'cite_error_ref_too_many_keys',
|
||||
'expected' => 'cite_error_ref_follow_conflicts',
|
||||
],
|
||||
// Validating <ref> outside of <references>
|
||||
'text-only <ref>' => [
|
||||
|
|
Loading…
Reference in a new issue