mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-12 01:01:29 +00:00
Merge "Introduce dedicated error message for nested <ref extends=…>"
This commit is contained in:
commit
6ad54f0d63
|
@ -21,6 +21,7 @@
|
|||
"cite_error_ref_numeric_key": "Invalid <code><ref></code> tag;\nname 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 <code><ref></code> tag;\ninvalid names, e.g. too many",
|
||||
"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;\nrefs with no name must have content",
|
||||
"cite_error_references_duplicate_key": "Invalid <code><ref></code> tag; name \"$1\" defined multiple times with different content",
|
||||
"cite_error_references_invalid_parameters": "Invalid parameter in <code><references></code> tag",
|
||||
|
|
|
@ -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><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": "Error message shown when ref tags has parameters other than name and group. Examples that cause this error are <code><ref name=\"name\" notname=\"value\"/></code> or <code><ref notname=\"value\" >input<ref></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><ref></ref></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><references someparameter=\"value\"/></code>.",
|
||||
|
|
|
@ -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'] );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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'] ) ) {
|
||||
|
|
|
@ -243,8 +243,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">[1.1]</a></sup>
|
||||
<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>
|
||||
<span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Extending <code><ref></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>
|
||||
|
|
|
@ -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" .
|
||||
|
|
Loading…
Reference in a new issue