r68157 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68156‎ | r68157 | r68158 >
Date:08:00, 17 June 2010
Author:reedy
Status:resolved (Comments)
Tags:
Comment:
Minor followup to r68156, add "user" as implicit group

Refactor out and reuse in ApiQueryUserInfo

Add couple more braces to SpecialUserrights
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryUserInfo.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryUsers.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUserrights.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryUserInfo.php
@@ -76,7 +76,9 @@
7777 }
7878
7979 if ( isset( $this->prop['groups'] ) ) {
80 - $vals['groups'] = $wgUser->getGroups();
 80+ $autolist = ApiQueryUsers::getAutoGroups( $wgUser );
 81+
 82+ $vals['groups'] = array_merge( $autolist, $wgUser->getGroups() );
8183 $result->setIndexedTagName( $vals['groups'], 'g' ); // even if empty
8284 }
8385
Index: trunk/phase3/includes/api/ApiQueryUsers.php
@@ -201,11 +201,7 @@
202202 }
203203 } else {
204204 if ( isset( $this->prop['groups'] ) && isset( $data[$u]['groups'] ) ) {
205 - $autolist = array();
206 - $autolist[] = "*";
207 - foreach( Autopromote::getAutopromoteGroups( User::newFromName( $u ) ) as $group ) {
208 - $autolist[] = $group;
209 - }
 205+ $autolist = ApiQueryUsers::getAutoGroups( User::newFromName( $u ) );
210206
211207 $data[$u]['groups'] = array_merge( $autolist, $data[$u]['groups'] );
212208
@@ -223,7 +219,19 @@
224220 }
225221 return $this->getResult()->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'user' );
226222 }
 223+
 224+ public static function getAutoGroups( $user ) {
 225+ $autolist = array();
 226+ $autolist[] = "*";
 227+ $autolist[] = "user";
227228
 229+ foreach( Autopromote::getAutopromoteGroups( $user ) as $group ) {
 230+ $autolist[] = $group;
 231+ }
 232+
 233+ return $autolist;
 234+ }
 235+
228236 public function getAllowedParams() {
229237 return array(
230238 'prop' => array(
Index: trunk/phase3/includes/specials/SpecialUserrights.php
@@ -402,8 +402,9 @@
403403 global $wgOut, $wgUser, $wgLang;
404404
405405 $list = array();
406 - foreach( $groups as $group )
 406+ foreach( $groups as $group ) {
407407 $list[] = self::buildGroupLink( $group );
 408+ }
408409
409410 $autolist = array();
410411 if ( $user instanceof User ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r68161Followup to r68157: simplify ApiQueryUsers::getAutoGroups()catrope09:39, 17 June 2010
r68331Followup r68157 and r68161 per Bryans comment (anons aren't in the group user)reedy17:30, 20 June 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r68156* (bug 24009) Include implicit groups in action=query&list=users&usprop=groups...reedy07:39, 17 June 2010

Comments

#Comment by Bryan (talk | contribs)   09:29, 18 June 2010

'user' is not an implicit group for anons. I also get autoconfirmed as autopromote group, but that may also be my local settings.

<?xml version="1.0"?>
<api>
  <query>
    <userinfo id="0" name="127.0.0.1" anon="">
      <groups>
        <g>*</g>
        <g>user</g>
        <g>autoconfirmed</g>
      </groups>
    </userinfo>
  </query>
</api>
#Comment by Reedy (talk | contribs)   11:07, 18 June 2010

If the "autoconfirmed" group is wrong on your wiki, that's a bug in Autopromote::getAutopromoteGroups()..

For listusers, you are right, the user is wrong, but for allusers, you can't use it on Anon, so that's not an issue.

Will tidy this up later (ie add check for Anon and not add the "user" group)

#Comment by Bryan (talk | contribs)   19:10, 9 December 2010

This magic should really be inside the User class, but that's minor. Resolved.

Status & tagging log