jenkins-bot has submitted this change and it was merged.
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(-)
Approvals:
Tobias Gritschacher: Looks good to me, approved
jenkins-bot: Verified
diff --git a/repo/includes/api/EditEntity.php b/repo/includes/api/EditEntity.php
index 9059edf..b81826d 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: merged
Gerrit-Change-Id: I3373ffacc01837fc858526f573b8e347af422c1d
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Daniel Werner <[email protected]>
Gerrit-Reviewer: Denny Vrandecic <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits