r98356 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98355‎ | r98356 | r98357 >
Date:19:34, 28 September 2011
Author:reedy
Status:ok
Tags:
Comment:
MFT r98329, r98332 (and whitespace for ApiQueryAllUsers from r98330)
Modified paths:
  • /branches/REL1_18/phase3/includes/api/ApiQueryAllUsers.php (modified) (history)
  • /branches/REL1_18/phase3/includes/api/ApiQueryUserInfo.php (modified) (history)
  • /branches/REL1_18/phase3/includes/api/ApiQueryUsers.php (modified) (history)
  • /branches/wmf/1.18wmf1/includes/api/ApiQueryAllUsers.php (modified) (history)
  • /branches/wmf/1.18wmf1/includes/api/ApiQueryUserInfo.php (modified) (history)
  • /branches/wmf/1.18wmf1/includes/api/ApiQueryUsers.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/includes/api/ApiQueryUserInfo.php
@@ -83,6 +83,11 @@
8484 $result->setIndexedTagName( $vals['groups'], 'g' ); // even if empty
8585 }
8686
 87+ if ( isset( $this->prop['implicitgroups'] ) ) {
 88+ $vals['implicitgroups'] = ApiQueryUsers::getAutoGroups( $wgUser );
 89+ $result->setIndexedTagName( $vals['implicitgroups'], 'g' ); // even if empty
 90+ }
 91+
8792 if ( isset( $this->prop['rights'] ) ) {
8893 // User::getRights() may return duplicate values, strip them
8994 $vals['rights'] = array_values( array_unique( $wgUser->getRights() ) );
@@ -191,6 +196,7 @@
192197 'blockinfo',
193198 'hasmsg',
194199 'groups',
 200+ 'implicitgroups',
195201 'rights',
196202 'changeablegroups',
197203 'options',
@@ -213,6 +219,7 @@
214220 ' blockinfo - Tags if the current user is blocked, by whom, and for what reason',
215221 ' hasmsg - Adds a tag "message" if the current user has pending messages',
216222 ' groups - Lists all the groups the current user belongs to',
 223+ ' implicitgroups - Lists all the groups the current user is automatically a member of',
217224 ' rights - Lists all the rights the current user has',
218225 ' changeablegroups - Lists the groups the current user can add to and remove from',
219226 ' options - Lists all preferences the current user has set',
Index: branches/wmf/1.18wmf1/includes/api/ApiQueryAllUsers.php
@@ -51,8 +51,9 @@
5252 $fld_groups = isset( $prop['groups'] );
5353 $fld_rights = isset( $prop['rights'] );
5454 $fld_registration = isset( $prop['registration'] );
 55+ $fld_implicitgroups = isset( $prop['implicitgroups'] );
5556 } else {
56 - $fld_blockinfo = $fld_editcount = $fld_groups = $fld_registration = $fld_rights = false;
 57+ $fld_blockinfo = $fld_editcount = $fld_groups = $fld_registration = $fld_rights = $fld_implicitgroups = false;
5758 }
5859
5960 $limit = $params['limit'];
@@ -246,13 +247,17 @@
247248 $result->setIndexedTagName( $lastUserData['groups'], 'g' );
248249 }
249250
 251+ if ( $fld_implicitgroups && !isset( $lastUserData['implicitgroups'] ) ) {
 252+ $lastUserData['implicitgroups'] = ApiQueryUsers::getAutoGroups( User::newFromName( $lastUser ) );
 253+ $result->setIndexedTagName( $lastUserData['implicitgroups'], 'g' );
 254+ }
250255 if ( $fld_rights ) {
251256 if ( !isset( $lastUserData['rights'] ) ) {
252257 $lastUserData['rights'] = User::getGroupPermissions( User::newFromName( $lastUser )->getAutomaticGroups() );
253258 }
254259 if ( !is_null( $row->ug_group2 ) ) {
255260 $lastUserData['rights'] = array_unique( array_merge( $lastUserData['rights'],
256 - User::getGroupPermissions( array( $row->ug_group2 ) ) ) );
 261+ User::getGroupPermissions( array( $row->ug_group2 ) ) ) );
257262 }
258263 $result->setIndexedTagName( $lastUserData['rights'], 'r' );
259264 }
@@ -304,6 +309,7 @@
305310 ApiBase::PARAM_TYPE => array(
306311 'blockinfo',
307312 'groups',
 313+ 'implicitgroups',
308314 'rights',
309315 'editcount',
310316 'registration'
@@ -333,11 +339,12 @@
334340 'rights' => 'Limit users to given right(s)',
335341 'prop' => array(
336342 'What pieces of information to include.',
337 - ' blockinfo - Adds the information about a current block on the user',
338 - ' groups - Lists groups that the user is in. This uses more server resources and may return fewer results than the limit',
339 - ' rights - Lists rights that the user has',
340 - ' editcount - Adds the edit count of the user',
341 - ' registration - Adds the timestamp of when the user registered if available (may be blank)',
 343+ ' blockinfo - Adds the information about a current block on the user',
 344+ ' groups - Lists groups that the user is in. This uses more server resources and may return fewer results than the limit',
 345+ ' implicitgroups - Lists all the groups the user is automatically in',
 346+ ' rights - Lists rights that the user has',
 347+ ' editcount - Adds the edit count of the user',
 348+ ' registration - Adds the timestamp of when the user registered if available (may be blank)',
342349 ),
343350 'limit' => 'How many total user names to return',
344351 'witheditsonly' => 'Only list users who have made edits',
Index: branches/wmf/1.18wmf1/includes/api/ApiQueryUsers.php
@@ -152,6 +152,10 @@
153153 }
154154 }
155155
 156+ if ( isset( $this->prop['implicitgroups'] ) && !isset( $data[$name]['implicitgroups'] ) ) {
 157+ $data[$name]['implicitgroups'] = self::getAutoGroups( $user );
 158+ }
 159+
156160 if ( isset( $this->prop['rights'] ) ) {
157161 if ( !isset( $data[$name]['rights'] ) ) {
158162 $data[$name]['rights'] = User::getGroupPermissions( $user->getAutomaticGroups() );
@@ -226,6 +230,9 @@
227231 if ( isset( $this->prop['groups'] ) && isset( $data[$u]['groups'] ) ) {
228232 $result->setIndexedTagName( $data[$u]['groups'], 'g' );
229233 }
 234+ if ( isset( $this->prop['implicitgroups'] ) && isset( $data[$u]['implicitgroups'] ) ) {
 235+ $result->setIndexedTagName( $data[$u]['implicitgroups'], 'g' );
 236+ }
230237 if ( isset( $this->prop['rights'] ) && isset( $data[$u]['rights'] ) ) {
231238 $result->setIndexedTagName( $data[$u]['rights'], 'r' );
232239 }
@@ -256,12 +263,7 @@
257264 $groups[] = 'user';
258265 }
259266
260 - $builtGroups = array();
261 - foreach( array_merge( $groups, Autopromote::getAutopromoteGroups( $user ) ) as $i => $group ) {
262 - $builtGroups[$i] = array( 'implicit' => '' );
263 - ApiResult::setContent( $builtGroups[$i], $group );
264 - }
265 - return $builtGroups;
 267+ return array_merge( $groups, Autopromote::getAutopromoteGroups( $user ) );
266268 }
267269
268270 public function getCacheMode( $params ) {
@@ -280,6 +282,7 @@
281283 ApiBase::PARAM_TYPE => array(
282284 'blockinfo',
283285 'groups',
 286+ 'implicitgroups',
284287 'rights',
285288 'editcount',
286289 'registration',
@@ -301,13 +304,14 @@
302305 return array(
303306 'prop' => array(
304307 'What pieces of information to include',
305 - ' blockinfo - Tags if the user is blocked, by whom, and for what reason',
306 - ' groups - Lists all the groups the user(s) belongs to',
307 - ' rights - Lists all the rights the user(s) has',
308 - ' editcount - Adds the user\'s edit count',
309 - ' registration - Adds the user\'s registration timestamp',
310 - ' emailable - Tags if the user can and wants to receive e-mail through [[Special:Emailuser]]',
311 - ' gender - Tags the gender of the user. Returns "male", "female", or "unknown"',
 308+ ' blockinfo - Tags if the user is blocked, by whom, and for what reason',
 309+ ' groups - Lists all the groups the user(s) belongs to',
 310+ ' implicitgroups - Lists all the groups a user is automatically a member of',
 311+ ' rights - Lists all the rights the user(s) has',
 312+ ' editcount - Adds the user\'s edit count',
 313+ ' registration - Adds the user\'s registration timestamp',
 314+ ' emailable - Tags if the user can and wants to receive e-mail through [[Special:Emailuser]]',
 315+ ' gender - Tags the gender of the user. Returns "male", "female", or "unknown"',
312316 ),
313317 'users' => 'A list of users to obtain the same information for',
314318 'token' => 'Which tokens to obtain for each user',
Index: branches/REL1_18/phase3/includes/api/ApiQueryUserInfo.php
@@ -83,6 +83,11 @@
8484 $result->setIndexedTagName( $vals['groups'], 'g' ); // even if empty
8585 }
8686
 87+ if ( isset( $this->prop['implicitgroups'] ) ) {
 88+ $vals['implicitgroups'] = ApiQueryUsers::getAutoGroups( $wgUser );
 89+ $result->setIndexedTagName( $vals['implicitgroups'], 'g' ); // even if empty
 90+ }
 91+
8792 if ( isset( $this->prop['rights'] ) ) {
8893 // User::getRights() may return duplicate values, strip them
8994 $vals['rights'] = array_values( array_unique( $wgUser->getRights() ) );
@@ -191,6 +196,7 @@
192197 'blockinfo',
193198 'hasmsg',
194199 'groups',
 200+ 'implicitgroups',
195201 'rights',
196202 'changeablegroups',
197203 'options',
@@ -213,6 +219,7 @@
214220 ' blockinfo - Tags if the current user is blocked, by whom, and for what reason',
215221 ' hasmsg - Adds a tag "message" if the current user has pending messages',
216222 ' groups - Lists all the groups the current user belongs to',
 223+ ' implicitgroups - Lists all the groups the current user is automatically a member of',
217224 ' rights - Lists all the rights the current user has',
218225 ' changeablegroups - Lists the groups the current user can add to and remove from',
219226 ' options - Lists all preferences the current user has set',
Index: branches/REL1_18/phase3/includes/api/ApiQueryAllUsers.php
@@ -51,8 +51,9 @@
5252 $fld_groups = isset( $prop['groups'] );
5353 $fld_rights = isset( $prop['rights'] );
5454 $fld_registration = isset( $prop['registration'] );
 55+ $fld_implicitgroups = isset( $prop['implicitgroups'] );
5556 } else {
56 - $fld_blockinfo = $fld_editcount = $fld_groups = $fld_registration = $fld_rights = false;
 57+ $fld_blockinfo = $fld_editcount = $fld_groups = $fld_registration = $fld_rights = $fld_implicitgroups = false;
5758 }
5859
5960 $limit = $params['limit'];
@@ -246,13 +247,17 @@
247248 $result->setIndexedTagName( $lastUserData['groups'], 'g' );
248249 }
249250
 251+ if ( $fld_implicitgroups && !isset( $lastUserData['implicitgroups'] ) ) {
 252+ $lastUserData['implicitgroups'] = ApiQueryUsers::getAutoGroups( User::newFromName( $lastUser ) );
 253+ $result->setIndexedTagName( $lastUserData['implicitgroups'], 'g' );
 254+ }
250255 if ( $fld_rights ) {
251256 if ( !isset( $lastUserData['rights'] ) ) {
252257 $lastUserData['rights'] = User::getGroupPermissions( User::newFromName( $lastUser )->getAutomaticGroups() );
253258 }
254259 if ( !is_null( $row->ug_group2 ) ) {
255260 $lastUserData['rights'] = array_unique( array_merge( $lastUserData['rights'],
256 - User::getGroupPermissions( array( $row->ug_group2 ) ) ) );
 261+ User::getGroupPermissions( array( $row->ug_group2 ) ) ) );
257262 }
258263 $result->setIndexedTagName( $lastUserData['rights'], 'r' );
259264 }
@@ -304,6 +309,7 @@
305310 ApiBase::PARAM_TYPE => array(
306311 'blockinfo',
307312 'groups',
 313+ 'implicitgroups',
308314 'rights',
309315 'editcount',
310316 'registration'
@@ -333,11 +339,12 @@
334340 'rights' => 'Limit users to given right(s)',
335341 'prop' => array(
336342 'What pieces of information to include.',
337 - ' blockinfo - Adds the information about a current block on the user',
338 - ' groups - Lists groups that the user is in. This uses more server resources and may return fewer results than the limit',
339 - ' rights - Lists rights that the user has',
340 - ' editcount - Adds the edit count of the user',
341 - ' registration - Adds the timestamp of when the user registered if available (may be blank)',
 343+ ' blockinfo - Adds the information about a current block on the user',
 344+ ' groups - Lists groups that the user is in. This uses more server resources and may return fewer results than the limit',
 345+ ' implicitgroups - Lists all the groups the user is automatically in',
 346+ ' rights - Lists rights that the user has',
 347+ ' editcount - Adds the edit count of the user',
 348+ ' registration - Adds the timestamp of when the user registered if available (may be blank)',
342349 ),
343350 'limit' => 'How many total user names to return',
344351 'witheditsonly' => 'Only list users who have made edits',
Index: branches/REL1_18/phase3/includes/api/ApiQueryUsers.php
@@ -152,6 +152,10 @@
153153 }
154154 }
155155
 156+ if ( isset( $this->prop['implicitgroups'] ) && !isset( $data[$name]['implicitgroups'] ) ) {
 157+ $data[$name]['implicitgroups'] = self::getAutoGroups( $user );
 158+ }
 159+
156160 if ( isset( $this->prop['rights'] ) ) {
157161 if ( !isset( $data[$name]['rights'] ) ) {
158162 $data[$name]['rights'] = User::getGroupPermissions( $user->getAutomaticGroups() );
@@ -226,6 +230,9 @@
227231 if ( isset( $this->prop['groups'] ) && isset( $data[$u]['groups'] ) ) {
228232 $result->setIndexedTagName( $data[$u]['groups'], 'g' );
229233 }
 234+ if ( isset( $this->prop['implicitgroups'] ) && isset( $data[$u]['implicitgroups'] ) ) {
 235+ $result->setIndexedTagName( $data[$u]['implicitgroups'], 'g' );
 236+ }
230237 if ( isset( $this->prop['rights'] ) && isset( $data[$u]['rights'] ) ) {
231238 $result->setIndexedTagName( $data[$u]['rights'], 'r' );
232239 }
@@ -256,12 +263,7 @@
257264 $groups[] = 'user';
258265 }
259266
260 - $builtGroups = array();
261 - foreach( array_merge( $groups, Autopromote::getAutopromoteGroups( $user ) ) as $i => $group ) {
262 - $builtGroups[$i] = array( 'implicit' => '' );
263 - ApiResult::setContent( $builtGroups[$i], $group );
264 - }
265 - return $builtGroups;
 267+ return array_merge( $groups, Autopromote::getAutopromoteGroups( $user ) );
266268 }
267269
268270 public function getCacheMode( $params ) {
@@ -280,6 +282,7 @@
281283 ApiBase::PARAM_TYPE => array(
282284 'blockinfo',
283285 'groups',
 286+ 'implicitgroups',
284287 'rights',
285288 'editcount',
286289 'registration',
@@ -301,13 +304,14 @@
302305 return array(
303306 'prop' => array(
304307 'What pieces of information to include',
305 - ' blockinfo - Tags if the user is blocked, by whom, and for what reason',
306 - ' groups - Lists all the groups the user(s) belongs to',
307 - ' rights - Lists all the rights the user(s) has',
308 - ' editcount - Adds the user\'s edit count',
309 - ' registration - Adds the user\'s registration timestamp',
310 - ' emailable - Tags if the user can and wants to receive e-mail through [[Special:Emailuser]]',
311 - ' gender - Tags the gender of the user. Returns "male", "female", or "unknown"',
 308+ ' blockinfo - Tags if the user is blocked, by whom, and for what reason',
 309+ ' groups - Lists all the groups the user(s) belongs to',
 310+ ' implicitgroups - Lists all the groups a user is automatically a member of',
 311+ ' rights - Lists all the rights the user(s) has',
 312+ ' editcount - Adds the user\'s edit count',
 313+ ' registration - Adds the user\'s registration timestamp',
 314+ ' emailable - Tags if the user can and wants to receive e-mail through [[Special:Emailuser]]',
 315+ ' gender - Tags the gender of the user. Returns "male", "female", or "unknown"',
312316 ),
313317 'users' => 'A list of users to obtain the same information for',
314318 'token' => 'Which tokens to obtain for each user',

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r98329Bug 31199 - Fix notification of implicit groups so it doesn't massively chang...reedy16:36, 28 September 2011
r98330Fix whitespacereedy16:37, 28 September 2011
r98332Followup r98329...reedy17:01, 28 September 2011

Status & tagging log