Merge "Introduce dedicated error message for nested <ref extends=…>"

This commit is contained in:
jenkins-bot 2020-01-24 10:58:01 +00:00 committed by Gerrit Code Review
commit 6ad54f0d63
6 changed files with 8 additions and 7 deletions

View file

@ -21,6 +21,7 @@
"cite_error_ref_numeric_key": "Invalid <code>&lt;ref&gt;</code> tag;\nname cannot be a simple integer. Use a descriptive title",
"cite_error_ref_no_key": "The opening <code>&lt;ref&gt;</code> tag is malformed or has a bad name",
"cite_error_ref_too_many_keys": "Invalid <code>&lt;ref&gt;</code> tag;\ninvalid names, e.g. too many",
"cite_error_ref_nested_extends": "Extending <code>&lt;ref&gt;</code> tags more than one level deep is not allowed",
"cite_error_ref_no_input": "Invalid <code>&lt;ref&gt;</code> tag;\nrefs with no name must have content",
"cite_error_references_duplicate_key": "Invalid <code>&lt;ref&gt;</code> tag; name \"$1\" defined multiple times with different content",
"cite_error_references_invalid_parameters": "Invalid parameter in <code>&lt;references&gt;</code> tag",

View file

@ -22,6 +22,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>&lt;ref name=\"123\"/&gt;</code> or <code>&lt;ref name=\"456\">input</ref&gt;</code>",
"cite_error_ref_no_key": "Error message shown when ref tags without any content (that is <code>&lt;ref/&gt;</code>) are used without a name.",
"cite_error_ref_too_many_keys": "Error message shown when ref tags has parameters other than name and group. Examples that cause this error are <code>&lt;ref name=\"name\" notname=\"value\"/&gt;</code> or <code>&lt;ref notname=\"value\" >input<ref&gt;</code>",
"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>&lt;ref></ref&gt;</code>",
"cite_error_references_duplicate_key": "Error message shown when multiple refs with same name exist but with different content",
"cite_error_references_invalid_parameters": "Error message shown when parameters are used in the references tag. An example that causes this error is <code>&lt;references someparameter=\"value\"/&gt;</code>.",

View file

@ -180,8 +180,8 @@ class Cite {
return StatusValue::newFatal( 'cite_error_references_duplicate_key', $name );
} elseif ( isset( $groupRefs[$extends]['extends'] ) ) {
// A sub-reference can not be extended a second time (no nesting)
// TODO: Introduce a specific error for this case, reuse in formatReferences()!
return StatusValue::newFatal( 'cite_error_ref_too_many_keys' );
return StatusValue::newFatal( 'cite_error_ref_nested_extends', $extends,
$groupRefs[$extends]['extends'] );
}
}

View file

@ -119,8 +119,8 @@ class ReferencesFormatter {
isset( $groupRefs[$value['extends']]['extends'] )
) {
$value['text'] = ( $value['text'] ?? '' ) . ' ' .
// TODO: Introduce a specific error for this case; reuse in validateRef()!
$this->errorReporter->plain( $parser, 'cite_error_ref_too_many_keys' );
$this->errorReporter->plain( $parser, 'cite_error_ref_nested_extends',
$value['extends'], $groupRefs[$value['extends']]['extends'] );
}
if ( !$indented && isset( $value['extends'] ) ) {

View file

@ -243,8 +243,7 @@ wgCiteBookReferencing=true
!! html/php
<p><sup id="cite_ref-a_1-0" class="reference"><a href="#cite_note-a-1">&#91;1&#93;</a></sup>
<sup id="cite_ref-b_2-0" class="reference"><a href="#cite_note-b-2">&#91;1.1&#93;</a></sup>
<span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag;
invalid names, e.g. too many</span>
<span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Extending <code>&lt;ref&gt;</code> tags more than one level deep is not allowed</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</span>

View file

@ -126,7 +126,7 @@ class ReferencesFormatterTest extends \MediaWikiUnitTestCase {
'<div class="mw-references-wrap"><ol class="references">' . "\n" .
'<li>(cite_references_link_many|||<span class="reference-text">t3</span>' . "\n" .
'|)<ol class="mw-extended-references"><li>(cite_references_link_many|||' .
'<span class="reference-text">t1 (cite_error_ref_too_many_keys)</span>' .
'<span class="reference-text">t1 (cite_error_ref_nested_extends|a|b)</span>' .
"\n|)</li>\n" .
'<li>(cite_references_link_many|||<span class="reference-text">t2</span>' .
"\n|)</li>\n</ol></li>\n" .