* (bug 26559) list=allusers auprop=rights does not match list=users usprop=rights
authorSam Reed <reedy@users.mediawiki.org>
Tue, 4 Jan 2011 03:36:39 +0000 (03:36 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Tue, 4 Jan 2011 03:36:39 +0000 (03:36 +0000)
RELEASE-NOTES
includes/api/ApiQueryAllUsers.php
includes/api/ApiQueryUsers.php

index ff3b49b..cb7f87b 100644 (file)
@@ -68,6 +68,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * action=parse now correctly returns an error for nonexistent pages
 * (bug 25767) Add userrights properties to allusers and users query lists
 * (bug 26558) list=allusers auprop=groups does not list groups a user is automatically a member of
+* (bug 26559) list=allusers auprop=rights does not match list=users usprop=rights
 
 === Languages updated in 1.18 ===
 
index a7994b6..2042e68 100644 (file)
@@ -112,6 +112,7 @@ class ApiQueryAllUsers extends ApiQueryBase {
                } else {
                        $sqlLimit = $limit + 1;
                }
+
                if ( $fld_blockinfo ) {
                        $this->addTables( 'ipblocks' );
                        $this->addTables( 'user', 'u2' );
index 59fcbf7..4dc4d41 100644 (file)
@@ -126,6 +126,9 @@ if ( !defined( 'MEDIAWIKI' ) ) {
 
                        $data = array();
                        $res = $this->select( __METHOD__ );
+
+                       $result = $this->getResult();
+
                        foreach ( $res as $row ) {
                                $user = User::newFromRow( $row );
                                $name = $user->getName();
@@ -140,14 +143,23 @@ if ( !defined( 'MEDIAWIKI' ) ) {
                                }
 
                                if ( isset( $this->prop['groups'] ) && !is_null( $row->ug_group ) ) {
+                                       if ( !isset( $data[$u]['groups'] ) ) {
+                                               $data[$u]['groups'] = ApiQueryUsers::getAutoGroups( User::newFromName( $u ) );
+                                       }
+
                                        // This row contains only one group, others will be added from other rows
                                        $data[$name]['groups'][] = $row->ug_group;
+                                       $result->setIndexedTagName( $data[$u]['groups'], 'g' );
                                }
 
-                               if ( isset( $this->prop['rights'] ) && !isset( $data[$name]['rights'] ) ) {
-                                       // User::getRights() may return duplicate values, strip them
-                                       $data[$name]['rights'] = array_values( array_unique( $user->getRights() ) );
-                                       $result->setIndexedTagName( $data[$name]['rights'], 'r' );      // even if empty
+                               if ( isset( $this->prop['rights'] ) && !is_null( $row->ug_group ) ) {
+                                       if ( !isset( $data[$name]['rights'] ) ) {
+                                               $data[$name]['rights'] = User::getGroupPermissions( User::getImplicitGroups() );
+                                       }
+
+                                       $data[$name]['rights'] = array_unique( array_merge( $data[$name]['rights'],
+                                               User::getGroupPermissions( array( $row->ug_group ) ) ) );
+                                       $result->setIndexedTagName( $data[$name]['rights'], 'r' );
                                }
 
                                if ( isset( $this->prop['blockinfo'] ) && !is_null( $row->blocker_name ) ) {
@@ -206,15 +218,8 @@ if ( !defined( 'MEDIAWIKI' ) ) {
                                } else {
                                        $data[$u]['missing'] = '';
                                }
-                       } else {
-                               if ( isset( $this->prop['groups'] ) && isset( $data[$u]['groups'] ) ) {
-                                       $autolist = ApiQueryUsers::getAutoGroups( User::newFromName( $u ) );
-
-                                       $data[$u]['groups'] = array_merge( $autolist, $data[$u]['groups'] );
-
-                                       $this->getResult()->setIndexedTagName( $data[$u]['groups'], 'g' );
-                               }
                        }
+
                        $fit = $result->addValue( array( 'query', $this->getModuleName() ),
                                        null, $data[$u] );
                        if ( !$fit ) {