API: Handle shorthand "all groups" configuration in ApiQuerySiteInfo
authorBrad Jorsch <bjorsch@wikimedia.org>
Tue, 17 May 2016 13:35:10 +0000 (09:35 -0400)
committerUmherirrender <umherirrender_de.wp@web.de>
Thu, 19 May 2016 18:53:57 +0000 (18:53 +0000)
In $wgAddGroups, $wgRemoveGroups, $wgGroupsAddToSelf, and
$wgGroupsRemoveFromSelf, boolean true in place of an array of groups to
allow adding/removing is shorthand for "all groups". Handle this
appropriately in action=query&meta=siteinfo&siprop=usergroups.

Bug: T135467
Change-Id: I6ae61ef14ac7932e3369155c56bad60a9d72060d

includes/api/ApiQuerySiteinfo.php

index a08740a..0774651 100644 (file)
@@ -485,7 +485,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
 
                $data = [];
                $result = $this->getResult();
-               $allGroups = User::getAllGroups();
+               $allGroups = array_values( User::getAllGroups() );
                foreach ( $config->get( 'GroupPermissions' ) as $group => $permissions ) {
                        $arr = [
                                'name' => $group,
@@ -512,7 +512,11 @@ class ApiQuerySiteinfo extends ApiQueryBase {
 
                        foreach ( $groupArr as $type => $rights ) {
                                if ( isset( $rights[$group] ) ) {
-                                       $groups = array_intersect( $rights[$group], $allGroups );
+                                       if ( $rights[$group] === true ) {
+                                               $groups = $allGroups;
+                                       } else {
+                                               $groups = array_intersect( $rights[$group], $allGroups );
+                                       }
                                        if ( $groups ) {
                                                $arr[$type] = $groups;
                                                ApiResult::setArrayType( $arr[$type], 'BCarray' );