Addshore has uploaded a new change for review.
https://gerrit.wikimedia.org/r/78665
Change subject: Cleanup incorrect params in wbeditentity
......................................................................
Cleanup incorrect params in wbeditentity
When trying to write the test for this module
I found that quite often the wrong error was
given. These changes should now make the error
code given to the user more accurate and will
also catch more stuff that previousl sliped
through the checks
Change-Id: I3373ffacc01837fc858526f573b8e347af422c1d
---
M repo/includes/api/EditEntity.php
1 file changed, 11 insertions(+), 7 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/65/78665/1
diff --git a/repo/includes/api/EditEntity.php b/repo/includes/api/EditEntity.php
index cc8c9c0..f7af6b3 100644
--- a/repo/includes/api/EditEntity.php
+++ b/repo/includes/api/EditEntity.php
@@ -81,15 +81,19 @@
* @see \Wikibase\Api\ModifyEntity::validateParameters()
*/
protected function validateParameters( array $params ) {
- // note that this is changed back and could fail
- if ( !( isset( $params['data'] ) OR isset( $params['id'] ) XOR
( isset( $params['site'] ) && isset( $params['title'] ) ) ) ) {
- $this->dieUsage( 'Either provide the item "id" or pairs
of "site" and "title" for a corresponding page, or "data" for a new item',
'param-missing' );
+ $hasId = isset( $params['id'] );
+ $hasNew = isset( $params['new'] );
+ $hasSitelink = ( isset( $params['site'] ) && isset(
$params['title'] ) );
+ $hasSitelinkPart = ( isset( $params['site'] ) || isset(
$params['title'] ) );
+
+ if ( !( $hasId XOR $hasSitelink XOR $hasNew ) ) {
+ $this->dieUsage( 'Either provide the item "id" or pairs
of "site" and "title" or a "new" type for an entity' , 'param-missing' );
}
- if ( isset( $params['id'] ) && isset( $params['new'] ) ) {
- $this->dieUsage( "Parameter 'id' and 'new' are not
allowed to be both set in the same request", 'param-illegal' );
+ if( $hasId && $hasSitelink ){
+ $this->dieUsage( "Parameter 'id' and 'site', 'title'
combination are not allowed to be both set in the same request",
'param-illegal' );
}
- if ( !isset( $params['id'] ) && !isset( $params['new'] ) ) {
- $this->dieUsage( "Either 'id' or 'new' parameter has to
be set", 'no-such-entity' );
+ if( ( $hasId || $hasSitelinkPart ) && $hasNew ){
+ $this->dieUsage( "Parameters 'id', 'site', 'title' and
'new' are not allowed to be both set in the same request", 'param-illegal' );
}
}
--
To view, visit https://gerrit.wikimedia.org/r/78665
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3373ffacc01837fc858526f573b8e347af422c1d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits