Aude has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/177090

Change subject: Add array_key_exists check for language in EditEntity api module
......................................................................

Add array_key_exists check for language in EditEntity api module

when checking multilingual arguments for label or description
changes, 'language' is required in the label or description json
serialization supplied by the user and we try to access
$arg['language'] in the code.  First, we should check that
this key exists and if not, provide an appropriate error response,
in order to avoid php notices and give better error information.

Bug: T76516
Change-Id: If502b2ad917f54a1cc25a8d42fe3b03837d80e50
---
M repo/includes/api/EditEntity.php
1 file changed, 7 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/90/177090/1

diff --git a/repo/includes/api/EditEntity.php b/repo/includes/api/EditEntity.php
index 2d246d0..45b10ae 100644
--- a/repo/includes/api/EditEntity.php
+++ b/repo/includes/api/EditEntity.php
@@ -808,6 +808,13 @@
                                "An array was expected, but not found in the 
json for the langCode {$langCode}" ,
                                'not-recognized-array' );
                }
+
+               if ( !array_key_exists( 'language', $arg ) ) {
+                       $this->dieError(
+                               "'language' was not found in the label or 
description json for {$langCode}",
+                                       'missing-language' );
+               }
+
                if ( !is_string( $arg['language'] ) ) {
                        $this->dieError(
                                "A string was expected, but not found in the 
json for the langCode {$langCode} and argument 'language'" ,

-- 
To view, visit https://gerrit.wikimedia.org/r/177090
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If502b2ad917f54a1cc25a8d42fe3b03837d80e50
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aude <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to