<ref>
tag;\nname cannot be a simple integer. Use a descriptive title",
"cite_error_ref_no_key": "The opening <ref>
tag is malformed or has a bad name",
"cite_error_ref_too_many_keys": "Invalid <ref>
tag;\ninvalid names, e.g. too many",
+ "cite_error_ref_nested_extends": "Extending <ref>
tags more than one level deep is not allowed",
"cite_error_ref_no_input": "Invalid <ref>
tag;\nrefs with no name must have content",
"cite_error_references_duplicate_key": "Invalid <ref>
tag; name \"$1\" defined multiple times with different content",
"cite_error_references_invalid_parameters": "Invalid parameter in <references>
tag",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index d9f1d3725..ea728ebdb 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -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 <ref name=\"123\"/>
or <ref name=\"456\">input",
"cite_error_ref_no_key": "Error message shown when ref tags without any content (that is <ref/>
) 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 <ref name=\"name\" notname=\"value\"/>
or <ref notname=\"value\" >input",
+ "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 <ref>
",
"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 <references someparameter=\"value\"/>
.",
diff --git a/src/Cite.php b/src/Cite.php
index 1c2f5d3aa..e0097eb1f 100644
--- a/src/Cite.php
+++ b/src/Cite.php
@@ -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'] );
}
}
diff --git a/src/ReferencesFormatter.php b/src/ReferencesFormatter.php
index 354ca6e97..0e18334fc 100644
--- a/src/ReferencesFormatter.php
+++ b/src/ReferencesFormatter.php
@@ -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'] ) ) {
diff --git a/tests/parser/bookReferencing.txt b/tests/parser/bookReferencing.txt
index daa626698..4ffaa0708 100644
--- a/tests/parser/bookReferencing.txt
+++ b/tests/parser/bookReferencing.txt
@@ -243,8 +243,7 @@ wgCiteBookReferencing=true
!! html/php
[1]
[1.1]
-Cite error: Invalid <ref>
tag;
-invalid names, e.g. too many
+Cite error: Extending <ref>
tags more than one level deep is not allowed
- ↑ book
diff --git a/tests/phpunit/unit/ReferencesFormatterTest.php b/tests/phpunit/unit/ReferencesFormatterTest.php
index 3c34285ca..0efb297b2 100644
--- a/tests/phpunit/unit/ReferencesFormatterTest.php
+++ b/tests/phpunit/unit/ReferencesFormatterTest.php
@@ -126,7 +126,7 @@ class ReferencesFormatterTest extends \MediaWikiUnitTestCase {
'
' . "\n" .
'- (cite_references_link_many|||t3' . "\n" .
'|)
- (cite_references_link_many|||' .
- 't1 (cite_error_ref_too_many_keys)' .
+ 't1 (cite_error_ref_nested_extends|a|b)' .
"\n|)
\n" .
'- (cite_references_link_many|||t2' .
"\n|)
\n
\n" .