Eranroz has uploaded a new change for review. https://gerrit.wikimedia.org/r/226464
Change subject: Show an error if a named ref is defined multiple times ...................................................................... Show an error if a named ref is defined multiple times Bug: T85386 Change-Id: I6e7a7594628b3e0c09724c11e5d9f650dde25906 --- M Cite_body.php M citeParserTests.txt M i18n/en.json M i18n/qqq.json 4 files changed, 10 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cite refs/changes/64/226464/1 diff --git a/Cite_body.php b/Cite_body.php index f1b1445..26815c7 100644 --- a/Cite_body.php +++ b/Cite_body.php @@ -457,6 +457,10 @@ $this->mRefCallStack[] = array( 'assign', $call, $str, $key, $group, $this->mRefs[$group][$key]['key'] ); } else { + if ( $str !== '' && $str !== $this->mRefs[$group][$key]['text'] ) { + // two refs with same key and different content + $this->mReferencesErrors[] = $this->error( 'cite_error_references_duplicate_key', $key ); + } $this->mRefCallStack[] = array( 'increment', $call, $str, $key, $group, $this->mRefs[$group][$key]['key'] ); } diff --git a/citeParserTests.txt b/citeParserTests.txt index acd3056..b67aa90 100644 --- a/citeParserTests.txt +++ b/citeParserTests.txt @@ -194,7 +194,8 @@ <li id="cite_note-blank-1"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-blank_1-0">1.0</a></sup> <sup><a href="#cite_ref-blank_1-1">1.1</a></sup></span> <span class="reference-text">0</span> </li> </ol> - +<p><strong class="error mw-ext-cite-error">Cite error: Invalid ref "blank"; defined multiple times with different content</strong> +</p> !! end !! test @@ -213,7 +214,8 @@ <li id="cite_note-blank-1"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-blank_1-0">1.0</a></sup> <sup><a href="#cite_ref-blank_1-1">1.1</a></sup></span> <span class="reference-text">1</span> </li> </ol> - +<p><strong class="error mw-ext-cite-error">Cite error: Invalid ref "blank"; defined multiple times with different content</strong> +</p> !! end !! test diff --git a/i18n/en.json b/i18n/en.json index 5c5ad60..2e281c8 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -20,6 +20,7 @@ "cite_error_ref_no_key": "Invalid <code><ref></code> tag;\nrefs with no content must have a name", "cite_error_ref_too_many_keys": "Invalid <code><ref></code> tag;\ninvalid names, e.g. too many", "cite_error_ref_no_input": "Invalid <code><ref></code> tag;\nrefs with no name must have content", + "cite_error_references_duplicate_key": "Invalid ref \"$1\"; defined multiple times with different content", "cite_error_references_invalid_parameters": "Invalid <code><references></code> tag;\nno parameters are allowed.\nUse <code><references /></code>", "cite_error_references_invalid_parameters_group": "Invalid <code><references></code> tag;\nparameter \"group\" is allowed only.\nUse <code><references /></code>, or <code><references group=\"...\" /></code>", "cite_error_references_no_backlink_label": "Ran out of custom backlink labels.\nDefine more in the <nowiki>[[MediaWiki:Cite references link many format backlink labels]]</nowiki> message.", diff --git a/i18n/qqq.json b/i18n/qqq.json index 5798902..0900547 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -21,6 +21,7 @@ "cite_error_ref_no_key": "Cite extension. Error message shown when ref tags without any content (that is <code><nowiki><ref /></nowiki></code>) are used without a name.", "cite_error_ref_too_many_keys": "Cite extension. Error message shown when ref tags has parameters other than name and group. Examples that cause this error are <code><nowiki><ref name=\"name\" notname=\"value\" /></nowiki></code> or <code><nowiki><ref notname=\"value\" >input<ref></nowiki></code>", "cite_error_ref_no_input": "Cite extension. Error message shown when ref tags without names have no content. An example that cause this error is <code><nowiki><ref></ref></nowiki></code>", + "cite_error_references_duplicate_key": "Cite extension. Error message shown when multiple refs with same name exist but with different content", "cite_error_references_invalid_parameters": "Cite extension. Error message shown when parmeters are used in the references tag. An example that cause this error is <code><nowiki><references someparameter=\"value\" /></nowiki></code>", "cite_error_references_invalid_parameters_group": "Cite extension. Error message shown when unknown parameters are used in the references tag. An example that cause this error is <samp><nowiki><references someparameter=\"value\" /></nowiki></samp>", "cite_error_references_no_backlink_label": "Cite extension. Error message shown in the references tag when the same name is used for too many ref tags. Too many in this case is more than there are backlink labels defined in [[MediaWiki:Cite references link many format backlink labels]].\n\nIt is not possible to make a clickable link to this message. \"nowiki\" is mandatory around [[MediaWiki:Cite references link many format backlink labels]].", -- To view, visit https://gerrit.wikimedia.org/r/226464 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6e7a7594628b3e0c09724c11e5d9f650dde25906 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Cite Gerrit-Branch: master Gerrit-Owner: Eranroz <eranro...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits