aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--RELEASE-NOTES-1.416
-rw-r--r--includes/Permissions/PermissionManager.php44
-rw-r--r--includes/user/User.php53
-rw-r--r--tests/phpunit/includes/Permissions/PermissionManagerTest.php78
-rw-r--r--tests/phpunit/includes/user/UserTest.php61
5 files changed, 6 insertions, 236 deletions
diff --git a/RELEASE-NOTES-1.41 b/RELEASE-NOTES-1.41
index 7a0818967a13..35614a785976 100644
--- a/RELEASE-NOTES-1.41
+++ b/RELEASE-NOTES-1.41
@@ -469,6 +469,12 @@ because of Phabricator reports.
* Title::getTouched() will now trigger an error if you pass it an instance of
IDatabase rather than a READ_XXX constant. This legacy behaviour has been
deprecated since 1.38.
+* User::getGroupPermissions(), getGroupsWithPermission() & groupHasPermission(),
+ all of which were deprecated since 1.34, have been removed. Instead, use the
+ GroupPermissionsLookup service.
+* Similarly, PermissionManager::getGroupPermissions(), getGroupsWithPermission()
+ & groupHasPermission(), all of which were deprecated since 1.36, have also
+ been removed. Instead, use the GroupPermissionsLookup service.
* The following old, deprecated aliases for classes in the RDBMS layer, have now
been removed:
- DBConnRef (use Wikimedia\Rdbms\DBConnRef)
diff --git a/includes/Permissions/PermissionManager.php b/includes/Permissions/PermissionManager.php
index d4d909852493..b2c07ad7e154 100644
--- a/includes/Permissions/PermissionManager.php
+++ b/includes/Permissions/PermissionManager.php
@@ -1620,50 +1620,6 @@ class PermissionManager {
}
/**
- * Check, if the given group has the given permission
- *
- * If you're wanting to check whether all users have a permission, use
- * PermissionManager::isEveryoneAllowed() instead. That properly checks if it's revoked
- * from anyone.
- *
- * @since 1.34
- * @deprecated since 1.36, hard-deprecated since 1.40. Use GroupPermissionsLookup instead.
- * @param string $group Group to check
- * @param string $role Role to check
- * @return bool
- */
- public function groupHasPermission( $group, $role ): bool {
- wfDeprecated( __METHOD__, '1.36' );
- return $this->groupPermissionsLookup->groupHasPermission( $group, $role );
- }
-
- /**
- * Get the permissions associated with a given list of groups
- *
- * @since 1.34
- * @deprecated since 1.36, hard-deprecated since 1.40. Use GroupPermissionsLookup instead.
- * @param string[] $groups internal group names
- * @return string[] permission key names for given groups combined
- */
- public function getGroupPermissions( $groups ): array {
- wfDeprecated( __METHOD__, '1.36' );
- return $this->groupPermissionsLookup->getGroupPermissions( $groups );
- }
-
- /**
- * Get all the groups who have a given permission
- *
- * @since 1.34
- * @deprecated since 1.36, hard-deprecated since 1.40. use GroupPermissionsLookup instead.
- * @param string $role Role to check
- * @return string[] internal group names with the given permission
- */
- public function getGroupsWithPermission( $role ): array {
- wfDeprecated( __METHOD__, '1.36' );
- return $this->groupPermissionsLookup->getGroupsWithPermission( $role );
- }
-
- /**
* Check if all users may be assumed to have the given permission
*
* We generally assume so if the right is granted to '*' and isn't revoked
diff --git a/includes/user/User.php b/includes/user/User.php
index e3fc671c5c17..9822c7034d9b 100644
--- a/includes/user/User.php
+++ b/includes/user/User.php
@@ -3279,59 +3279,6 @@ class User implements Authority, UserIdentity, UserEmailContact {
}
/**
- * Get the permissions associated with a given list of groups
- *
- * @deprecated since 1.34, hard-deprecated since 1.40, use
- * GroupPermissionsLookup::getGroupPermissions() instead in 1.36+, or
- * PermissionManager::getGroupPermissions() in 1.34 and 1.35.
- *
- * @param string[] $groups internal group names
- * @return string[] permission key names for given groups combined
- */
- public static function getGroupPermissions( $groups ) {
- wfDeprecated( __METHOD__, '1.34' );
- return MediaWikiServices::getInstance()->getGroupPermissionsLookup()->getGroupPermissions( $groups );
- }
-
- /**
- * Get all the groups who have a given permission
- *
- * @deprecated since 1.34, hard-deprecated since 1.40, use
- * GroupPermissionsLookup::getGroupsWithPermission() instead in 1.36+,
- * or PermissionManager::getGroupsWithPermission() in 1.34 and 1.35.
- *
- * @param string $role Role to check
- * @return string[] internal group names with the given permission
- */
- public static function getGroupsWithPermission( $role ) {
- wfDeprecated( __METHOD__, '1.34' );
- return MediaWikiServices::getInstance()->getGroupPermissionsLookup()
- ->getGroupsWithPermission( $role );
- }
-
- /**
- * Check, if the given group has the given permission
- *
- * If you're wanting to check whether all users have a permission, use
- * PermissionManager::isEveryoneAllowed() instead. That properly checks if it's revoked
- * from anyone.
- *
- * @deprecated since 1.34, hard-deprecated since 1.40, use
- * GroupPermissionsLookup::groupHasPermission() instead in 1.36+, or
- * PermissionManager::groupHasPermission() in 1.34 and 1.35.
- *
- * @since 1.21
- * @param string $group Group to check
- * @param string $role Role to check
- * @return bool
- */
- public static function groupHasPermission( $group, $role ) {
- wfDeprecated( __METHOD__, '1.34' );
- return MediaWikiServices::getInstance()->getGroupPermissionsLookup()
- ->groupHasPermission( $group, $role );
- }
-
- /**
* Return the set of defined explicit groups.
* The implicit groups (by default *, 'user' and 'autoconfirmed')
* are not included, as they are defined automatically, not in the database.
diff --git a/tests/phpunit/includes/Permissions/PermissionManagerTest.php b/tests/phpunit/includes/Permissions/PermissionManagerTest.php
index af9dfcf93fc4..aaba752dc998 100644
--- a/tests/phpunit/includes/Permissions/PermissionManagerTest.php
+++ b/tests/phpunit/includes/Permissions/PermissionManagerTest.php
@@ -1022,67 +1022,6 @@ class PermissionManagerTest extends MediaWikiLangTestCase {
$this->assertNotContains( 'nukeworld', $rights );
}
- public function testGroupPermissions() {
- $this->hideDeprecated( 'MediaWiki\\Permissions\\PermissionManager::getGroupPermissions' );
- $rights = $this->getServiceContainer()->getPermissionManager()
- ->getGroupPermissions( [ 'unittesters' ] );
- $this->assertContains( 'runtest', $rights );
- $this->assertNotContains( 'writetest', $rights );
- $this->assertNotContains( 'modifytest', $rights );
- $this->assertNotContains( 'nukeworld', $rights );
-
- $rights = $this->getServiceContainer()->getPermissionManager()
- ->getGroupPermissions( [ 'unittesters', 'testwriters' ] );
- $this->assertContains( 'runtest', $rights );
- $this->assertContains( 'writetest', $rights );
- $this->assertContains( 'modifytest', $rights );
- $this->assertNotContains( 'nukeworld', $rights );
- }
-
- public function testRevokePermissions() {
- $this->hideDeprecated( 'MediaWiki\\Permissions\\PermissionManager::getGroupPermissions' );
- $rights = $this->getServiceContainer()->getPermissionManager()
- ->getGroupPermissions( [ 'unittesters', 'formertesters' ] );
- $this->assertNotContains( 'runtest', $rights );
- $this->assertNotContains( 'writetest', $rights );
- $this->assertNotContains( 'modifytest', $rights );
- $this->assertNotContains( 'nukeworld', $rights );
- }
-
- /**
- * @dataProvider provideGetGroupsWithPermission
- */
- public function testGetGroupsWithPermission( $expected, $right ) {
- $this->hideDeprecated( 'MediaWiki\\Permissions\\PermissionManager::getGroupsWithPermission' );
- $result = $this->getServiceContainer()->getPermissionManager()
- ->getGroupsWithPermission( $right );
- sort( $result );
- sort( $expected );
-
- $this->assertEquals( $expected, $result, "Groups with permission $right" );
- }
-
- public static function provideGetGroupsWithPermission() {
- return [
- [
- [ 'unittesters', 'testwriters' ],
- 'test'
- ],
- [
- [ 'unittesters' ],
- 'runtest'
- ],
- [
- [ 'testwriters' ],
- 'writetest'
- ],
- [
- [ 'testwriters' ],
- 'modifytest'
- ],
- ];
- }
-
public function testUserHasRight() {
$permissionManager = $this->getServiceContainer()->getPermissionManager();
@@ -1123,23 +1062,6 @@ class PermissionManagerTest extends MediaWikiLangTestCase {
$this->assertTrue( $result, 'empty action should always be granted' );
}
- public function testGroupHasPermission() {
- $this->hideDeprecated( 'MediaWiki\\Permissions\\PermissionManager::groupHasPermission' );
- $permissionManager = $this->getServiceContainer()->getPermissionManager();
-
- $result = $permissionManager->groupHasPermission(
- 'unittesters',
- 'test'
- );
- $this->assertTrue( $result );
-
- $result = $permissionManager->groupHasPermission(
- 'formertesters',
- 'runtest'
- );
- $this->assertFalse( $result );
- }
-
public function testIsEveryoneAllowed() {
$permissionManager = $this->getServiceContainer()->getPermissionManager();
diff --git a/tests/phpunit/includes/user/UserTest.php b/tests/phpunit/includes/user/UserTest.php
index 04104430410d..5eb3cc719c02 100644
--- a/tests/phpunit/includes/user/UserTest.php
+++ b/tests/phpunit/includes/user/UserTest.php
@@ -105,67 +105,6 @@ class UserTest extends MediaWikiIntegrationTestCase {
}
/**
- * @covers User::getGroupPermissions
- */
- public function testGroupPermissions() {
- $this->hideDeprecated( 'MediaWiki\User\User::getGroupPermissions' );
- $rights = User::getGroupPermissions( [ 'unittesters' ] );
- $this->assertContains( 'runtest', $rights );
- $this->assertNotContains( 'writetest', $rights );
- $this->assertNotContains( 'modifytest', $rights );
- $this->assertNotContains( 'nukeworld', $rights );
-
- $rights = User::getGroupPermissions( [ 'unittesters', 'testwriters' ] );
- $this->assertContains( 'runtest', $rights );
- $this->assertContains( 'writetest', $rights );
- $this->assertContains( 'modifytest', $rights );
- $this->assertNotContains( 'nukeworld', $rights );
- }
-
- /**
- * @covers User::getGroupPermissions
- */
- public function testRevokePermissions() {
- $this->hideDeprecated( 'MediaWiki\User\User::getGroupPermissions' );
- $rights = User::getGroupPermissions( [ 'unittesters', 'formertesters' ] );
- $this->assertNotContains( 'runtest', $rights );
- $this->assertNotContains( 'writetest', $rights );
- $this->assertNotContains( 'modifytest', $rights );
- $this->assertNotContains( 'nukeworld', $rights );
- }
-
- /**
- * @dataProvider provideGetGroupsWithPermission
- * @covers User::getGroupsWithPermission
- */
- public function testGetGroupsWithPermission( array $expected, $right ) {
- $this->hideDeprecated( 'MediaWiki\User\User::getGroupsWithPermission' );
- $result = User::getGroupsWithPermission( $right );
- $this->assertArrayEquals( $expected, $result );
- }
-
- public static function provideGetGroupsWithPermission() {
- return [
- [
- [ 'unittesters', 'testwriters' ],
- 'test'
- ],
- [
- [ 'unittesters' ],
- 'runtest'
- ],
- [
- [ 'testwriters' ],
- 'writetest'
- ],
- [
- [ 'testwriters' ],
- 'modifytest'
- ],
- ];
- }
-
- /**
* @covers User::isAllowedAny
* @covers User::isAllowedAll
* @covers User::isAllowed