jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/366583 )
Change subject: Add name of the parameter to the "param-missing" API error ...................................................................... Add name of the parameter to the "param-missing" API error I'm only touching cases where a single parameter is missing. This patch leaves a few usages untouched where this message is used for more than one parameter. I leave this for a later patch to fix (also I0d2a471 already fixed most of them). Note that this patch here does not introduce a new issue. The unlocalized text descriptions of all "param-missing" are currently entirely hidden because the message *exists* (even if untranslated). Proof: https://www.wikidata.org/wiki/Special:ApiSandbox#action=wbgetentities&sites=dewiki The unlocalized description for this error is "Must request one site, one title, or an equal number of sites and titles", but this string does not surface any more. Change-Id: I3900f0b8d158aeeeb74b9caf713ce9ac6f5a4ad2 --- M repo/i18n/en.json M repo/i18n/qqq.json M repo/includes/Api/CreateClaim.php M repo/includes/Api/MergeItems.php M repo/includes/Api/SetQualifier.php 5 files changed, 8 insertions(+), 13 deletions(-) Approvals: Ladsgroup: Looks good to me, approved jenkins-bot: Verified diff --git a/repo/i18n/en.json b/repo/i18n/en.json index cddcac8..cc72ee3 100644 --- a/repo/i18n/en.json +++ b/repo/i18n/en.json @@ -357,7 +357,7 @@ "wikibase-api-not-recognized-array": "An array was expected, but not recognized.", "wikibase-api-not-recognized-language": "The supplied language code was not recognized.", "wikibase-api-not-recognized-string": "A string was expected, but not recognized.", - "wikibase-api-param-missing": "A parameter that is required was missing.", + "wikibase-api-param-missing": "The required parameter \"$1\" was missing.", "wikibase-api-param-illegal": "An illegal set of parameters have been used.", "wikibase-api-permissiondenied": "You do not have the permissions needed to carry out this action.", "wikibase-api-wrong-class": "Wrong class type detected.", diff --git a/repo/i18n/qqq.json b/repo/i18n/qqq.json index 0eabbdf..401a104 100644 --- a/repo/i18n/qqq.json +++ b/repo/i18n/qqq.json @@ -390,7 +390,7 @@ "wikibase-api-not-recognized-array": "!!DO NOT TRANSLATE!! An array was expected, but not recognized. The user probably passed the API a malformed parameter", "wikibase-api-not-recognized-language": "!!DO NOT TRANSLATE!! The supplied language identifier was not recognized. The user probably passed the API a malformed parameter", "wikibase-api-not-recognized-string": "!!DO NOT TRANSLATE!! A string was expected, but not recognized. The user probably passed the API a malformed parameter", - "wikibase-api-param-missing": "!!DO NOT TRANSLATE!! A parameter that is required was missing, General message for when a parameter is missing from a request", + "wikibase-api-param-missing": "Error message when an API parameter that is required was missing from a request.\n* $1 - name of the parameter", "wikibase-api-param-illegal": "!!DO NOT TRANSLATE!! An illegal set of parameters have been used, General message for when the parameters passed in a request conflict or do not pass the initial tests", "wikibase-api-permissiondenied": "!!DO NOT TRANSLATE!! the user making the request does not have the correct permissions or rights to carry out the request", "wikibase-api-wrong-class": "!!DO NOT TRANSLATE!! The wrong class type has been detected when trying to make the request, this could be and item isntead of a property.", diff --git a/repo/includes/Api/CreateClaim.php b/repo/includes/Api/CreateClaim.php index 50afb00..56837c7 100644 --- a/repo/includes/Api/CreateClaim.php +++ b/repo/includes/Api/CreateClaim.php @@ -114,8 +114,7 @@ private function validateParameters( array $params ) { if ( $params['snaktype'] === 'value' xor isset( $params['value'] ) ) { if ( $params['snaktype'] === 'value' ) { - $this->errorReporter->dieError( - 'A value needs to be provided when creating a claim with PropertyValueSnak snak', + $this->errorReporter->dieWithError( [ 'param-missing', 'value' ], 'param-missing' ); } else { @@ -127,8 +126,7 @@ } if ( !isset( $params['property'] ) ) { - $this->errorReporter->dieError( - 'A property ID needs to be provided when creating a claim with a Snak', + $this->errorReporter->dieWithError( [ 'param-missing', 'property' ], 'param-missing' ); } diff --git a/repo/includes/Api/MergeItems.php b/repo/includes/Api/MergeItems.php index 4d8e9d4..5b13cdb 100644 --- a/repo/includes/Api/MergeItems.php +++ b/repo/includes/Api/MergeItems.php @@ -82,7 +82,7 @@ */ private function getItemIdParam( array $parameters, $name ) { if ( !isset( $parameters[$name] ) ) { - $this->errorReporter->dieError( 'Missing parameter: ' . $name, 'param-missing' ); + $this->errorReporter->dieWithError( [ 'param-missing', $name ], 'param-missing' ); } $value = $parameters[$name]; diff --git a/repo/includes/Api/SetQualifier.php b/repo/includes/Api/SetQualifier.php index fb9adac..ce9c9f2 100644 --- a/repo/includes/Api/SetQualifier.php +++ b/repo/includes/Api/SetQualifier.php @@ -123,23 +123,20 @@ if ( !isset( $params['snakhash'] ) ) { if ( !isset( $params['snaktype'] ) ) { - $this->errorReporter->dieError( - 'When creating a new qualifier (ie when not providing a snakhash) a snaktype should be specified', + $this->errorReporter->dieWithError( [ 'param-missing', 'snaktype' ], 'param-missing' ); } if ( !isset( $params['property'] ) ) { - $this->errorReporter->dieError( - 'When creating a new qualifier (ie when not providing a snakhash) a property should be specified', + $this->errorReporter->dieWithError( [ 'param-missing', 'property' ], 'param-missing' ); } } if ( isset( $params['snaktype'] ) && $params['snaktype'] === 'value' && !isset( $params['value'] ) ) { - $this->errorReporter->dieError( - 'When setting a qualifier that is a PropertyValueSnak, the value needs to be provided', + $this->errorReporter->dieWithError( [ 'param-missing', 'value' ], 'param-missing' ); } -- To view, visit https://gerrit.wikimedia.org/r/366583 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I3900f0b8d158aeeeb74b9caf713ce9ac6f5a4ad2 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> Gerrit-Reviewer: Addshore <addshorew...@gmail.com> Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: Ladsgroup <ladsgr...@gmail.com> Gerrit-Reviewer: Siebrand <siebr...@kitano.nl> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits