From 1e8992ca7489e620d157d9a50d9aa5e611b84887 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Fri, 3 Aug 2012 21:41:44 +0200 Subject: [PATCH] Follow-up I0b781c11 (2a55449): use User::getAutomaticGroups(). No need to duplicate the code of User::getAutomaticGroups() in ApiQueryUsers::getAutoGroups(), instead just call that method directly. Also deprecated the latter in favour of the former and replaced all calls in core. Change-Id: I224cb610cbd6a927a4c7f7137951416368f8cb5d --- includes/api/ApiQueryAllUsers.php | 4 ++-- includes/api/ApiQueryUserInfo.php | 6 ++---- includes/api/ApiQueryUsers.php | 17 ++++++----------- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/includes/api/ApiQueryAllUsers.php b/includes/api/ApiQueryAllUsers.php index 1e29a64832..fcc0b02f70 100644 --- a/includes/api/ApiQueryAllUsers.php +++ b/includes/api/ApiQueryAllUsers.php @@ -252,7 +252,7 @@ class ApiQueryAllUsers extends ApiQueryBase { if ( $fld_groups ) { if ( !isset( $lastUserData['groups'] ) ) { if ( $lastUserObj ) { - $lastUserData['groups'] = ApiQueryUsers::getAutoGroups( $lastUserObj ); + $lastUserData['groups'] = $lastUserObj->getAutomaticGroups(); } else { // This should not normally happen $lastUserData['groups'] = array(); @@ -267,7 +267,7 @@ class ApiQueryAllUsers extends ApiQueryBase { } if ( $fld_implicitgroups && !isset( $lastUserData['implicitgroups'] ) && $lastUserObj ) { - $lastUserData['implicitgroups'] = ApiQueryUsers::getAutoGroups( $lastUserObj ); + $lastUserData['implicitgroups'] = $lastUserObj->getAutomaticGroups(); $result->setIndexedTagName( $lastUserData['implicitgroups'], 'g' ); } if ( $fld_rights ) { diff --git a/includes/api/ApiQueryUserInfo.php b/includes/api/ApiQueryUserInfo.php index d211918309..6690665944 100644 --- a/includes/api/ApiQueryUserInfo.php +++ b/includes/api/ApiQueryUserInfo.php @@ -76,14 +76,12 @@ class ApiQueryUserInfo extends ApiQueryBase { } if ( isset( $this->prop['groups'] ) ) { - $autolist = ApiQueryUsers::getAutoGroups( $user ); - - $vals['groups'] = array_merge( $autolist, $user->getGroups() ); + $vals['groups'] = $user->getEffectiveGroups(); $result->setIndexedTagName( $vals['groups'], 'g' ); // even if empty } if ( isset( $this->prop['implicitgroups'] ) ) { - $vals['implicitgroups'] = ApiQueryUsers::getAutoGroups( $user ); + $vals['implicitgroups'] = $user->getAutomaticGroups(); $result->setIndexedTagName( $vals['implicitgroups'], 'g' ); // even if empty } diff --git a/includes/api/ApiQueryUsers.php b/includes/api/ApiQueryUsers.php index 855e27090a..bf438d1d18 100644 --- a/includes/api/ApiQueryUsers.php +++ b/includes/api/ApiQueryUsers.php @@ -138,7 +138,7 @@ class ApiQueryUsers extends ApiQueryBase { if ( isset( $this->prop['groups'] ) ) { if ( !isset( $data[$name]['groups'] ) ) { - $data[$name]['groups'] = self::getAutoGroups( $user ); + $data[$name]['groups'] = $user->getAutomaticGroups(); } if ( !is_null( $row->ug_group ) ) { @@ -148,7 +148,7 @@ class ApiQueryUsers extends ApiQueryBase { } if ( isset( $this->prop['implicitgroups'] ) && !isset( $data[$name]['implicitgroups'] ) ) { - $data[$name]['implicitgroups'] = self::getAutoGroups( $user ); + $data[$name]['implicitgroups'] = $user->getAutomaticGroups(); } if ( isset( $this->prop['rights'] ) ) { @@ -249,20 +249,15 @@ class ApiQueryUsers extends ApiQueryBase { /** * Gets all the groups that a user is automatically a member of (implicit groups) + * + * @deprecated since 1.20; call User::getAutomaticGroups() directly. * @param $user User * @return array */ public static function getAutoGroups( $user ) { - // FIXME this logic is duplicated from User::getEffectiveGroups(), centralize this - $groups = array(); - $groups[] = '*'; + wfDeprecated( __METHOD__, '1.20' ); - if ( !$user->isAnon() ) { - $groups[] = 'user'; - $groups = array_merge( $groups, Autopromote::getAutopromoteGroups( $user ) ); - } - - return $groups; + return $user->getAutomaticGroups(); } public function getCacheMode( $params ) { -- 2.20.1