Drop User::getRights()

Deprecated since 1.34 and unused.

Bug: T277511
Change-Id: Ia798c62cdfe6ad6c6d7af8d68b95231883a071fe
This commit is contained in:
vladshapik 2021-11-09 09:46:59 +02:00
parent 80d3ece54a
commit 8d2be7706d
3 changed files with 3 additions and 80 deletions

View file

@ -202,13 +202,14 @@ because of Phabricator reports.
::getRawUser and ::getRawDescription, deprecated since 1.37, has been removed.
* ShellboxHttpClient class has been removed without deprecation. It was an
internal class used by ShellboxClientFactory.
* The following User methods, deprecated in 1.37, have been removed:
* The following hard deprecated User methods have been removed:
- ::resetIdByNameCache,
- ::getStubThreshold,
- ::matchEditTokenNoSuffix,
- ::changeableByGroup,
- ::changeableGroups,
- ::isAllowUsertalk
- ::isAllowUsertalk,
- ::getRights
* Http::$httpEngine, deprecated since 1.34, has been removed. The only available
HTTP engine is now Guzzle. CurlHttpRequest and PhpHttpRequest classes were
removed.

View file

@ -2788,20 +2788,6 @@ class User implements Authority, UserIdentity, UserEmailContact {
->getBoolOption( $this, 'prefershttps' );
}
/**
* Get the permissions this user has.
* @return string[] permission names
*
* @deprecated since 1.34, hard deprecated since 1.37
* Use MediaWikiServices::getInstance()->getPermissionManager()
* ->getUserPermissions(..) instead
*
*/
public function getRights() {
wfDeprecated( __METHOD__, '1.34' );
return MediaWikiServices::getInstance()->getPermissionManager()->getUserPermissions( $this );
}
/**
* Get the list of explicit group memberships this user has.
* The implicit * and user groups are not included.

View file

@ -128,70 +128,6 @@ class UserTest extends MediaWikiIntegrationTestCase {
$this->assertNotContains( 'nukeworld', $rights );
}
/**
* TODO: Remove. This is the same as PermissionManagerTest::testGetUserPermissions
* @covers User::getRights
*/
public function testUserPermissions() {
$this->hideDeprecated( 'User::getRights' );
$rights = $this->user->getRights();
$this->assertContains( 'runtest', $rights );
$this->assertNotContains( 'writetest', $rights );
$this->assertNotContains( 'modifytest', $rights );
$this->assertNotContains( 'nukeworld', $rights );
}
/**
* TODO: Remove. This is the same as PermissionManagerTest::testGetUserPermissionsHooks
* @covers User::getRights
*/
public function testUserGetRightsHooks() {
$this->hideDeprecated( 'User::getRights' );
$user = $this->getTestUser( [ 'unittesters', 'testwriters' ] )->getUser();
$userWrapper = TestingAccessWrapper::newFromObject( $user );
$rights = $user->getRights();
$this->assertContains( 'test', $rights, 'sanity check' );
$this->assertContains( 'runtest', $rights, 'sanity check' );
$this->assertContains( 'writetest', $rights, 'sanity check' );
$this->assertNotContains( 'nukeworld', $rights, 'sanity check' );
// Add a hook manipulating the rights
$this->setTemporaryHook( 'UserGetRights', static function ( $user, &$rights ) {
$rights[] = 'nukeworld';
$rights = array_diff( $rights, [ 'writetest' ] );
} );
MediaWikiServices::getInstance()->getPermissionManager()->invalidateUsersRightsCache( $user );
$rights = $user->getRights();
$this->assertContains( 'test', $rights );
$this->assertContains( 'runtest', $rights );
$this->assertNotContains( 'writetest', $rights );
$this->assertContains( 'nukeworld', $rights );
// Add a Session that limits rights
$mock = $this->getMockBuilder( stdClass::class )
->addMethods( [ 'getAllowedUserRights', 'deregisterSession', 'getSessionId' ] )
->getMock();
$mock->method( 'getAllowedUserRights' )->willReturn( [ 'test', 'writetest' ] );
$mock->method( 'getSessionId' )->willReturn(
new MediaWiki\Session\SessionId( str_repeat( 'X', 32 ) )
);
$session = MediaWiki\Session\TestUtils::getDummySession( $mock );
$mockRequest = $this->getMockBuilder( FauxRequest::class )
->onlyMethods( [ 'getSession' ] )
->getMock();
$mockRequest->method( 'getSession' )->willReturn( $session );
$userWrapper->mRequest = $mockRequest;
$this->resetServices();
$rights = $user->getRights();
$this->assertContains( 'test', $rights );
$this->assertNotContains( 'runtest', $rights );
$this->assertNotContains( 'writetest', $rights );
$this->assertNotContains( 'nukeworld', $rights );
}
/**
* @dataProvider provideGetGroupsWithPermission
* @covers User::getGroupsWithPermission