r83787 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83786‎ | r83787 | r83788 >
Date:22:23, 12 March 2011
Author:reedy
Status:ok
Tags:
Comment:
* (bug 28010) Passing a non existant user to list=users gives internal error
* (bug 27549) action=query&list=users&usprop=groups doesn't show implicit groups if a user doesn't have explicit groups

Also follows up r79556, where I'd done a couple of daft things... (accessing undefined objects)
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryUsers.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES
@@ -239,6 +239,9 @@
240240 * (bug 27897) list=allusers and list=users list hidden users
241241 * (bug 27717) API's exturlusage module does not respect $wgMiserMode
242242 * (bug 27588) list=filearchive&faprop=sha1 returns empty attribute
 243+* (bug 28010) Passing a non existant user to list=users gives internal error
 244+* (bug 27549) action=query&list=users&usprop=groups doesn't show implicit
 245+ groups if a user doesn't have explicit groups
243246
244247 === Languages updated in 1.18 ===
245248
Index: trunk/phase3/includes/api/ApiQueryUsers.php
@@ -109,12 +109,14 @@
110110 }
111111 }
112112
 113+ $result = $this->getResult();
 114+
113115 if ( count( $goodNames ) ) {
114116 $this->addTables( 'user' );
115117 $this->addFields( '*' );
116118 $this->addWhereFld( 'user_name', $goodNames );
117119
118 - if ( isset( $this->prop['groups'] ) ) {
 120+ if ( isset( $this->prop['groups'] ) || isset( $this->prop['rights'] ) ) {
119121 $this->addTables( 'user_groups' );
120122 $this->addJoinConds( array( 'user_groups' => array( 'LEFT JOIN', 'ug_user=user_id' ) ) );
121123 $this->addFields( 'ug_group' );
@@ -125,8 +127,6 @@
126128 $data = array();
127129 $res = $this->select( __METHOD__ );
128130
129 - $result = $this->getResult();
130 -
131131 foreach ( $res as $row ) {
132132 $user = User::newFromRow( $row );
133133 $name = $user->getName();
@@ -142,24 +142,26 @@
143143 $data[$name]['registration'] = wfTimestampOrNull( TS_ISO_8601, $user->getRegistration() );
144144 }
145145
146 - if ( isset( $this->prop['groups'] ) && !is_null( $row->ug_group ) ) {
147 - if ( !isset( $data[$u]['groups'] ) ) {
148 - $data[$u]['groups'] = ApiQueryUsers::getAutoGroups( User::newFromName( $u ) );
 146+ if ( isset( $this->prop['groups'] ) ) {
 147+ if ( !isset( $data[$name]['groups'] ) ) {
 148+ $data[$name]['groups'] = self::getAutoGroups( $user );
149149 }
150150
151 - // This row contains only one group, others will be added from other rows
152 - $data[$name]['groups'][] = $row->ug_group;
153 - $result->setIndexedTagName( $data[$u]['groups'], 'g' );
 151+ if ( !is_null( $row->ug_group ) ) {
 152+ // This row contains only one group, others will be added from other rows
 153+ $data[$name]['groups'][] = $row->ug_group;
 154+ }
154155 }
155156
156 - if ( isset( $this->prop['rights'] ) && !is_null( $row->ug_group ) ) {
 157+ if ( isset( $this->prop['rights'] ) ) {
157158 if ( !isset( $data[$name]['rights'] ) ) {
158159 $data[$name]['rights'] = User::getGroupPermissions( User::getImplicitGroups() );
159160 }
160161
161 - $data[$name]['rights'] = array_unique( array_merge( $data[$name]['rights'],
162 - User::getGroupPermissions( array( $row->ug_group ) ) ) );
163 - $result->setIndexedTagName( $data[$name]['rights'], 'r' );
 162+ if ( !is_null( $row->ug_group ) ) {
 163+ $data[$name]['rights'] = array_unique( array_merge( $data[$name]['rights'],
 164+ User::getGroupPermissions( array( $row->ug_group ) ) ) );
 165+ }
164166 }
165167 if ( $row->ipb_deleted ) {
166168 $data[$name]['hidden'] = '';
@@ -195,6 +197,7 @@
196198 }
197199 }
198200 }
 201+
199202 // Second pass: add result data to $retval
200203 foreach ( $goodNames as $u ) {
201204 if ( !isset( $data[$u] ) ) {
@@ -220,6 +223,13 @@
221224 } else {
222225 $data[$u]['missing'] = '';
223226 }
 227+ } else {
 228+ if ( isset( $this->prop['groups'] ) && isset( $data[$u]['groups'] ) ) {
 229+ $result->setIndexedTagName( $data[$u]['groups'], 'g' );
 230+ }
 231+ if ( isset( $this->prop['rights'] ) && isset( $data[$u]['rights'] ) ) {
 232+ $result->setIndexedTagName( $data[$u]['rights'], 'r' );
 233+ }
224234 }
225235
226236 $fit = $result->addValue( array( 'query', $this->getModuleName() ),
@@ -231,7 +241,7 @@
232242 }
233243 $done[] = $u;
234244 }
235 - return $this->getResult()->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'user' );
 245+ return $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'user' );
236246 }
237247
238248 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r839321.17wmf1: MFT r78990, r79844, r81548, r82022, r82193, r83061, r83067, r83583,...catrope17:59, 14 March 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r79556* (bug 26559) list=allusers auprop=rights does not match list=users usprop=ri...reedy03:36, 4 January 2011

Status & tagging log