[MediaWiki-commits] [Gerrit] Show an error if a named ref is defined multiple times - change (mediawiki...Cite)
jenkins-bot has submitted this change and it was merged. 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(-) Approvals: Bartosz Dziewoński: Looks good to me, approved jenkins-bot: Verified diff --git a/Cite_body.php b/Cite_body.php index 41021b0..71e08e6 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 != null && $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 72e899e..6c6f7ef 100644 --- a/citeParserTests.txt +++ b/citeParserTests.txt @@ -213,7 +213,8 @@ ↑ 1.0 1.1 0 - +Cite error: Invalid tag; name "blank" defined multiple times with different content + !! end !! test @@ -232,7 +233,8 @@ ↑ 1.0 1.1 1 - +Cite error: Invalid tag; name "blank" defined multiple times with different content + !! end !! test diff --git a/i18n/en.json b/i18n/en.json index 5c5ad60..8f758fd 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -20,6 +20,7 @@ "cite_error_ref_no_key": "Invalid tag;\nrefs with no content must have a name", "cite_error_ref_too_many_keys": "Invalid tag;\ninvalid names, e.g. too many", "cite_error_ref_no_input": "Invalid tag;\nrefs with no name must have content", + "cite_error_references_duplicate_key": "Invalid tag; name \"$1\" defined multiple times with different content", "cite_error_references_invalid_parameters": "Invalidtag;\nno parameters are allowed.\nUse ", "cite_error_references_invalid_parameters_group": "Invalid tag;\nparameter \"group\" is allowed only.\nUse , or ", "cite_error_references_no_backlink_label": "Ran out of custom backlink labels.\nDefine more in the [[MediaWiki:Cite references link many format backlink labels]] 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 ) 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 or input", "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 ", + "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 ", "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 ", "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: merged Gerrit-Change-Id: I6e7a7594628b3e0c09724c11e5d9f650dde25906 Gerrit-PatchSet: 5 Gerrit-Project: mediawiki/extensions/Cite Gerrit-Branch: master Gerrit-Owner: Eranroz Gerrit-Reviewer: Amire80 Gerrit-Reviewer: Bartosz Dziewoński Gerrit-Reviewer: Eranroz Gerrit-Reviewer: Jackmcbarn Gerrit-Reviewer: Jforrester Gerrit-Reviewer: jenkins-bot <> ___ Me
[MediaWiki-commits] [Gerrit] Show an error if a named ref is defined multiple times - change (mediawiki...Cite)
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 @@ ↑ 1.0 1.1 0 - +Cite error: Invalid ref "blank"; defined multiple times with different content + !! end !! test @@ -213,7 +214,8 @@ ↑ 1.0 1.1 1 - +Cite error: Invalid ref "blank"; defined multiple times with different content + !! 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 tag;\nrefs with no content must have a name", "cite_error_ref_too_many_keys": "Invalid tag;\ninvalid names, e.g. too many", "cite_error_ref_no_input": "Invalid 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": "Invalidtag;\nno parameters are allowed.\nUse ", "cite_error_references_invalid_parameters_group": "Invalid tag;\nparameter \"group\" is allowed only.\nUse , or ", "cite_error_references_no_backlink_label": "Ran out of custom backlink labels.\nDefine more in the [[MediaWiki:Cite references link many format backlink labels]] 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 ) 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 or input", "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 ", + "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 ", "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 ", "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 ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits