diff --git a/RELEASE-NOTES-1.37 b/RELEASE-NOTES-1.37 index 2dc755660c0..a8a776f453a 100644 --- a/RELEASE-NOTES-1.37 +++ b/RELEASE-NOTES-1.37 @@ -331,7 +331,7 @@ because of Phabricator reports. * wfLocalFile(), deprecated since 1.34, now emits deprecation warnings. * wfFindFile(), deprecated since 1.34, now emits deprecation warnings. * User::getRights(), deprecated since 1.34, now emits deprecation warnings. -* User::changeableGroups and ::changeableByGroup were deprecated, use +* User::changeableGroups and ::changeableByGroup were hard deprecated, use corresponding methods in UserGroupManager instead. * … diff --git a/includes/api/ApiQuery.php b/includes/api/ApiQuery.php index abfc7508a8b..08b355bd8c0 100644 --- a/includes/api/ApiQuery.php +++ b/includes/api/ApiQuery.php @@ -176,6 +176,7 @@ class ApiQuery extends ApiBase { 'WatchedItemStore', 'UserEditTracker', 'UserOptionsLookup', + 'UserGroupManager', ] ], 'filerepoinfo' => ApiQueryFileRepoInfo::class, diff --git a/includes/api/ApiQueryUserInfo.php b/includes/api/ApiQueryUserInfo.php index 5da4e49e840..514c92f6010 100644 --- a/includes/api/ApiQueryUserInfo.php +++ b/includes/api/ApiQueryUserInfo.php @@ -22,6 +22,7 @@ use MediaWiki\User\TalkPageNotificationManager; use MediaWiki\User\UserEditTracker; +use MediaWiki\User\UserGroupManager; use MediaWiki\User\UserOptionsLookup; /** @@ -61,6 +62,9 @@ class ApiQueryUserInfo extends ApiQueryBase { */ private $userOptionsLookup; + /** @var UserGroupManager */ + private $userGroupManager; + /** * @param ApiQuery $query * @param string $moduleName @@ -68,6 +72,7 @@ class ApiQueryUserInfo extends ApiQueryBase { * @param WatchedItemStore $watchedItemStore * @param UserEditTracker $userEditTracker * @param UserOptionsLookup $userOptionsLookup + * @param UserGroupManager $userGroupManager */ public function __construct( ApiQuery $query, @@ -75,13 +80,15 @@ class ApiQueryUserInfo extends ApiQueryBase { TalkPageNotificationManager $talkPageNotificationManager, WatchedItemStore $watchedItemStore, UserEditTracker $userEditTracker, - UserOptionsLookup $userOptionsLookup + UserOptionsLookup $userOptionsLookup, + UserGroupManager $userGroupManager ) { parent::__construct( $query, $moduleName, 'ui' ); $this->talkPageNotificationManager = $talkPageNotificationManager; $this->watchedItemStore = $watchedItemStore; $this->userEditTracker = $userEditTracker; $this->userOptionsLookup = $userOptionsLookup; + $this->userGroupManager = $userGroupManager; } public function execute() { @@ -188,7 +195,7 @@ class ApiQueryUserInfo extends ApiQueryBase { } if ( isset( $this->prop['changeablegroups'] ) ) { - $vals['changeablegroups'] = $user->changeableGroups(); + $vals['changeablegroups'] = $this->userGroupManager->getGroupsChangeableBy( $this->getAuthority() ); ApiResult::setIndexedTagName( $vals['changeablegroups']['add'], 'g' ); ApiResult::setIndexedTagName( $vals['changeablegroups']['remove'], 'g' ); ApiResult::setIndexedTagName( $vals['changeablegroups']['add-self'], 'g' ); diff --git a/includes/specials/SpecialUserrights.php b/includes/specials/SpecialUserrights.php index 3eaf201d65a..96d20fa9298 100644 --- a/includes/specials/SpecialUserrights.php +++ b/includes/specials/SpecialUserrights.php @@ -1074,7 +1074,7 @@ class UserrightsPage extends SpecialPage { * ] */ protected function changeableGroups() { - return $this->getUser()->changeableGroups(); + return $this->userGroupManager->getGroupsChangeableBy( $this->getContext()->getAuthority() ); } /** diff --git a/includes/user/User.php b/includes/user/User.php index 1d8efee0bff..8065034ff0d 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -4070,6 +4070,7 @@ class User implements Authority, IDBAccessObject, UserIdentity, UserEmailContact * @deprecated since 1.37 Use UserGroupManager::getGroupsChangeableByGroup instead. */ public static function changeableByGroup( $group ) { + wfDeprecated( __METHOD__, '1.37' ); return MediaWikiServices::getInstance() ->getUserGroupManager() ->getGroupsChangeableByGroup( $group ); @@ -4084,6 +4085,7 @@ class User implements Authority, IDBAccessObject, UserIdentity, UserEmailContact * @deprecated since 1.37 Use UserGroupManager::getGroupsChangeableBy instead. */ public function changeableGroups() { + wfDeprecated( __METHOD__, '1.37' ); return MediaWikiServices::getInstance() ->getUserGroupManager() ->getGroupsChangeableBy( $this ); diff --git a/tests/phpunit/includes/user/UserTest.php b/tests/phpunit/includes/user/UserTest.php index 27cc7db2ea8..d16887605a2 100644 --- a/tests/phpunit/includes/user/UserTest.php +++ b/tests/phpunit/includes/user/UserTest.php @@ -1973,6 +1973,7 @@ class UserTest extends MediaWikiIntegrationTestCase { */ public function testChangeableGroups() { $this->setMwGlobals( self::CHANGEABLE_GROUPS_TEST_CONFIG ); + $this->hideDeprecated( 'User::changeableGroups' ); $allGroups = User::getAllGroups(); @@ -2036,6 +2037,7 @@ class UserTest extends MediaWikiIntegrationTestCase { */ public function testChangeableByGroup( string $group, array $expected ) { $this->setMwGlobals( self::CHANGEABLE_GROUPS_TEST_CONFIG ); + $this->hideDeprecated( 'User::changeableByGroup' ); $this->assertGroupsEquals( $expected, User::changeableByGroup( $group ) ); }