[MediaWiki-commits] [Gerrit] Show an error if a named ref is defined multiple times - change (mediawiki...Cite)

2015-10-01 Thread jenkins-bot (Code Review)
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 
ref tag; name "blank" defined multiple times with 
different content
+
 !! end
 
 !! test
@@ -232,7 +233,8 @@
 ↑ 1.0 1.1 1
 
 
-
+Cite error: Invalid 
ref 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 ref tag;\nrefs 
with no content must have a name",
"cite_error_ref_too_many_keys": "Invalid ref 
tag;\ninvalid names, e.g. too many",
"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 
references tag;\nno parameters are allowed.\nUse 
references /",
"cite_error_references_invalid_parameters_group": "Invalid 
references tag;\nparameter \"group\" is allowed only.\nUse 
references /, or references group=\"...\" 
/",
"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: 

[MediaWiki-commits] [Gerrit] Show an error if a named ref is defined multiple times - change (mediawiki...Cite)

2015-07-22 Thread Eranroz (Code Review)
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-1span class=mw-cite-backlink↑ supa 
href=#cite_ref-blank_1-01.0/a/sup supa 
href=#cite_ref-blank_1-11.1/a/sup/span span 
class=reference-text0/span
 /li
 /ol
-
+pstrong class=error mw-ext-cite-errorCite error: Invalid ref blank; 
defined multiple times with different content/strong
+/p
 !! end
 
 !! test
@@ -213,7 +214,8 @@
 li id=cite_note-blank-1span class=mw-cite-backlink↑ supa 
href=#cite_ref-blank_1-01.0/a/sup supa 
href=#cite_ref-blank_1-11.1/a/sup/span span 
class=reference-text1/span
 /li
 /ol
-
+pstrong class=error mw-ext-cite-errorCite 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 codelt;refgt;/code tag;\nrefs 
with no content must have a name,
cite_error_ref_too_many_keys: Invalid codelt;refgt;/code 
tag;\ninvalid names, e.g. too many,
cite_error_ref_no_input: Invalid codelt;refgt;/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 
codelt;referencesgt;/code tag;\nno parameters are allowed.\nUse 
codelt;references /gt;/code,
cite_error_references_invalid_parameters_group: Invalid 
codelt;referencesgt;/code tag;\nparameter \group\ is allowed only.\nUse 
codelt;references /gt;/code, or codelt;references group=\...\ 
/gt;/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 codenowikiref //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 codenowikiref name=\name\ notname=\value\ 
//nowiki/code or codenowikiref notname=\value\ 
inputref/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 
codenowikiref/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 codenowikireferences 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 sampnowikireferences 
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