From fac144565411ba560c96b5913b2b054e48deadd7 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Thu, 19 Apr 2018 02:39:23 +0100 Subject: [PATCH] API: Fix PHP Warning for "count(): Parameter must be an array" Found by the new ApiUserrights test introduced in 5ab1bee6bcf: > includes/specials/SpecialUserrights.php:462 > includes/specials/SpecialUserrights.php:405 > includes/api/ApiUserrights.php:116 The $tags parameter of the UserrightsPage::doSaveUserGroups() method must be an array and is not nullable. Fix the caller to not pass null, but an empty array. Bug: T182377 Change-Id: Ic9be6a0bddfac023de765c810c07a64d651c33b4 --- includes/api/ApiUserrights.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/api/ApiUserrights.php b/includes/api/ApiUserrights.php index 56c2c84cc8..47f3bc5a4d 100644 --- a/includes/api/ApiUserrights.php +++ b/includes/api/ApiUserrights.php @@ -100,7 +100,7 @@ class ApiUserrights extends ApiBase { $tags = $params['tags']; // Check if user can add tags - if ( !is_null( $tags ) ) { + if ( $tags !== null ) { $ableToTag = ChangeTags::canAddTagsAccompanyingChange( $tags, $pUser ); if ( !$ableToTag->isOK() ) { $this->dieStatus( $ableToTag ); @@ -112,8 +112,9 @@ class ApiUserrights extends ApiBase { $r['user'] = $user->getName(); $r['userid'] = $user->getId(); list( $r['added'], $r['removed'] ) = $form->doSaveUserGroups( + // Don't pass null to doSaveUserGroups() for array params, cast to empty array $user, (array)$add, (array)$params['remove'], - $params['reason'], $tags, $groupExpiries + $params['reason'], (array)$tags, $groupExpiries ); $result = $this->getResult(); -- 2.20.1