Merge "list=allusers&aurights=[unusedright] returns all users of the wiki"
authorCatrope <roan.kattouw@gmail.com>
Mon, 29 Oct 2012 19:44:18 +0000 (19:44 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 29 Oct 2012 19:44:18 +0000 (19:44 +0000)
includes/api/ApiQueryAllUsers.php

index 7f50cba..79f6469 100644 (file)
@@ -81,12 +81,18 @@ class ApiQueryAllUsers extends ApiQueryBase {
                                $db->buildLike( $this->getCanonicalUserName( $params['prefix'] ), $db->anyString() ) );
                }
 
-               if ( !is_null( $params['rights'] ) ) {
+               if ( !is_null( $params['rights'] ) && count( $params['rights'] ) ) {
                        $groups = array();
                        foreach( $params['rights'] as $r ) {
                                $groups = array_merge( $groups, User::getGroupsWithPermission( $r ) );
                        }
 
+                       // no group with the given right(s) exists, no need for a query
+                       if( !count( $groups ) ) {
+                               $this->getResult()->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), '' );
+                               return;
+                       }
+
                        $groups = array_unique( $groups );
 
                        if ( is_null( $params['group'] ) ) {