list=allusers&aurights=[unusedright] returns all users of the wiki
authorumherirrender <umherirrender_de.wp@web.de>
Fri, 5 Oct 2012 19:03:17 +0000 (21:03 +0200)
committerGerrit Code Review <gerrit@wikimedia.org>
Sun, 28 Oct 2012 19:33:14 +0000 (19:33 +0000)
Filter for an unused right gives an empty group array, which
is not added to the query and than all users (with limit) are
selected.

Change-Id: I57c3c4d2b49653d71391b0d7755fdc0ad1d3a7d0

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'] ) ) {