Merge "API: Fix PHP Warning for "count(): Parameter must be an array"" into REL1_31
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 19 Apr 2018 22:10:36 +0000 (22:10 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 19 Apr 2018 22:10:36 +0000 (22:10 +0000)
includes/api/ApiUserrights.php

index 56c2c84..47f3bc5 100644 (file)
@@ -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();