Yurik has uploaded a new change for review.
https://gerrit.wikimedia.org/r/196485
Change subject: Report duplicate list label name error
......................................................................
Report duplicate list label name error
When updating the label of an existing list with this query
api.php?action=editlist&id=7&label=newlabel
It is possible that the user has another list with the same label.
This patch will show an error 'duplicatelabel'
Without this patch, API currently returns an internal SQL error
Change-Id: Ia5e056b3c16663afc0790d50eaafddd34b142f55
---
M includes/api/ApiEditList.php
1 file changed, 5 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Gather
refs/changes/85/196485/1
diff --git a/includes/api/ApiEditList.php b/includes/api/ApiEditList.php
index 0504f96..86f912e 100644
--- a/includes/api/ApiEditList.php
+++ b/includes/api/ApiEditList.php
@@ -290,7 +290,11 @@
}
if ( $update ) {
// ACTION: update list record
- $dbw->update( 'gather_list', $update, array( 'gl_id' =>
$row->gl_id ), __METHOD__ );
+ $dbw->update( 'gather_list', $update, array( 'gl_id' =>
$row->gl_id ), __METHOD__, 'IGNORE' );
+ if ( $dbw->affectedRows() === 0 ) {
+ // update failed due to the duplicate label
restriction. Report
+ $this->dieUsage( 'A list with this label
already exists', 'duplicatelabel' );
+ }
$this->getResult()->addValue( null,
$this->getModuleName(), array(
'status' => 'updated',
) );
--
To view, visit https://gerrit.wikimedia.org/r/196485
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia5e056b3c16663afc0790d50eaafddd34b142f55
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Gather
Gerrit-Branch: master
Gerrit-Owner: Yurik <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits