Drop User methods which were deprecated since 1.37
The following User methods, deprecated in 1.37, have been removed: - ::resetIdByNameCache, - ::getStubThreshold, - ::matchEditTokenNoSuffix, - ::changeableByGroup - ::changeableGroups, - ::isAllowUsertalk ActorStore::clearCaches() has been removed, since User::resetIdByNameCache has been removed. User::$mAllowUsertalk has been removed, since User::isAllowUsertalk has been removed. Bug: T277511 Change-Id: I608a5277924fc50cc3d9fca6ba958bc6d9c321d0
This commit is contained in:
parent
059e62cde6
commit
aac67c6c38
5 changed files with 7 additions and 211 deletions
|
|
@ -202,6 +202,13 @@ 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:
|
||||
- ::resetIdByNameCache,
|
||||
- ::getStubThreshold,
|
||||
- ::matchEditTokenNoSuffix,
|
||||
- ::changeableByGroup,
|
||||
- ::changeableGroups,
|
||||
- ::isAllowUsertalk
|
||||
* …
|
||||
|
||||
=== Deprecations in 1.38 ===
|
||||
|
|
|
|||
|
|
@ -1072,8 +1072,6 @@ class UserrightsPage extends SpecialPage {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns $this->getUser()->changeableGroups()
|
||||
*
|
||||
* @return array [
|
||||
* 'add' => [ addablegroups ],
|
||||
* 'remove' => [ removablegroups ],
|
||||
|
|
|
|||
|
|
@ -189,14 +189,6 @@ class ActorStore implements UserIdentityLookup, ActorNormalization {
|
|||
$this->cache->remove( $actor );
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal only exists until User::resetIdByNameCache is removed.
|
||||
* Wipe-out the in-process caches.
|
||||
*/
|
||||
public function clearCaches() {
|
||||
$this->cache->clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an actor by $id.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ use MediaWiki\Permissions\Authority;
|
|||
use MediaWiki\Permissions\PermissionStatus;
|
||||
use MediaWiki\Permissions\UserAuthority;
|
||||
use MediaWiki\Session\SessionManager;
|
||||
use MediaWiki\Session\Token;
|
||||
use MediaWiki\User\UserFactory;
|
||||
use MediaWiki\User\UserIdentity;
|
||||
use MediaWiki\User\UserIdentityValue;
|
||||
|
|
@ -240,13 +239,6 @@ class User implements Authority, UserIdentity, UserEmailContact {
|
|||
*/
|
||||
public $mBlock;
|
||||
|
||||
/**
|
||||
* TODO: This should be removed when User::isAllowUsertalk
|
||||
* is removed.
|
||||
* @var bool
|
||||
*/
|
||||
protected $mAllowUsertalk;
|
||||
|
||||
/** @var AbstractBlock|bool */
|
||||
private $mBlockedFromCreateAccount = false;
|
||||
|
||||
|
|
@ -945,18 +937,6 @@ class User implements Authority, UserIdentity, UserEmailContact {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the cache used in idFromName(). In tests, reset the service container.
|
||||
* There is no use-case for this in production code.
|
||||
*
|
||||
* @deprecated since 1.37.
|
||||
*/
|
||||
public static function resetIdByNameCache() {
|
||||
// TODO: when removing this call, also remove the ActorStore::clearCaches() method!
|
||||
wfDeprecated( __METHOD__, '1.37' );
|
||||
MediaWikiServices::getInstance()->getActorStore()->clearCaches();
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the string match an anonymous IP address?
|
||||
*
|
||||
|
|
@ -1644,13 +1624,11 @@ class User implements Authority, UserIdentity, UserEmailContact {
|
|||
$this->mBlockedby = $block->getByName();
|
||||
$this->mBlockreason = $block->getReason();
|
||||
$this->mHideName = $block->getHideName();
|
||||
$this->mAllowUsertalk = $block->isUsertalkEditAllowed();
|
||||
} else {
|
||||
$this->mBlock = null;
|
||||
$this->mBlockedby = '';
|
||||
$this->mBlockreason = '';
|
||||
$this->mHideName = 0;
|
||||
$this->mAllowUsertalk = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2810,19 +2788,6 @@ class User implements Authority, UserIdentity, UserEmailContact {
|
|||
->getBoolOption( $this, 'prefershttps' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user preferred stub threshold
|
||||
*
|
||||
* @deprecated since 1.37. The stub threshold preference support
|
||||
* was removed. See T284917
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getStubThreshold() {
|
||||
wfDeprecated( __METHOD__, '1.37' );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the permissions this user has.
|
||||
* @return string[] permission names
|
||||
|
|
@ -3660,23 +3625,6 @@ class User implements Authority, UserIdentity, UserEmailContact {
|
|||
return $this->getEditTokenObject( $salt, $request )->match( $val, $maxage );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check given value against the token value stored in the session,
|
||||
* ignoring the suffix.
|
||||
*
|
||||
* @deprecated since 1.37. No replacement was provided.
|
||||
* @param string $val Input value to compare
|
||||
* @param string|array $salt Optional function-specific data for hashing
|
||||
* @param WebRequest|null $request Object to use, or null to use the global request
|
||||
* @param int|null $maxage Fail tokens older than this, in seconds
|
||||
* @return bool Whether the token matches
|
||||
*/
|
||||
public function matchEditTokenNoSuffix( $val, $salt = '', $request = null, $maxage = null ) {
|
||||
wfDeprecated( __METHOD__, '1.37' );
|
||||
$val = substr( $val, 0, strspn( $val, '0123456789abcdef' ) ) . Token::SUFFIX;
|
||||
return $this->matchEditToken( $val, $salt, $request, $maxage );
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a new e-mail confirmation token and send a confirmation/invalidation
|
||||
* mail to the user's given address.
|
||||
|
|
@ -4044,38 +3992,6 @@ class User implements Authority, UserIdentity, UserEmailContact {
|
|||
->listAllImplicitGroups();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of the groups that a particular group can add/remove.
|
||||
*
|
||||
* @param string $group The group to check for whether it can add/remove
|
||||
* @return array [ 'add' => [ addablegroups ],
|
||||
* 'remove' => [ removablegroups ],
|
||||
* 'add-self' => [ addablegroups to self ],
|
||||
* 'remove-self' => [ removable groups from self ] ]
|
||||
* @deprecated since 1.37 Use UserGroupManager::getGroupsChangeableByGroup instead.
|
||||
*/
|
||||
public static function changeableByGroup( $group ) {
|
||||
wfDeprecated( __METHOD__, '1.37' );
|
||||
return MediaWikiServices::getInstance()
|
||||
->getUserGroupManager()
|
||||
->getGroupsChangeableByGroup( $group );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of groups that this user can add and remove
|
||||
* @return array [ 'add' => [ addablegroups ],
|
||||
* 'remove' => [ removablegroups ],
|
||||
* 'add-self' => [ addablegroups to self ],
|
||||
* 'remove-self' => [ removable groups from self ] ]
|
||||
* @deprecated since 1.37 Use UserGroupManager::getGroupsChangeableBy instead.
|
||||
*/
|
||||
public function changeableGroups() {
|
||||
wfDeprecated( __METHOD__, '1.37' );
|
||||
return MediaWikiServices::getInstance()
|
||||
->getUserGroupManager()
|
||||
->getGroupsChangeableBy( $this );
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule a deferred update to update the user's edit count
|
||||
* @deprecated since 1.37
|
||||
|
|
@ -4192,18 +4108,6 @@ class User implements Authority, UserIdentity, UserEmailContact {
|
|||
return $this->getName() === $user->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if usertalk is allowed
|
||||
*
|
||||
* @deprecated since 1.37 Use AbstractBlock::isUsertalkEditAllowed
|
||||
*
|
||||
* @return bool|null Returns null when no block has been loaded
|
||||
*/
|
||||
public function isAllowUsertalk() {
|
||||
wfDeprecated( __METHOD__, '1.37' );
|
||||
return $this->mAllowUsertalk;
|
||||
}
|
||||
|
||||
/**
|
||||
* @note This is only here for compatibility with the Authority interface.
|
||||
* @since 1.36
|
||||
|
|
|
|||
|
|
@ -1953,111 +1953,6 @@ class UserTest extends MediaWikiIntegrationTestCase {
|
|||
$this->assertSame( [ 'test3' ], $user->getGroups(), 'Hooks can stop removal of a group' );
|
||||
}
|
||||
|
||||
private const CHANGEABLE_GROUPS_TEST_CONFIG = [
|
||||
'wgGroupPermissions' => [
|
||||
'doEverything' => [
|
||||
'userrights' => true,
|
||||
],
|
||||
],
|
||||
'wgAddGroups' => [
|
||||
'sysop' => [ 'rollback' ],
|
||||
'bureaucrat' => [ 'sysop', 'bureaucrat' ],
|
||||
],
|
||||
'wgRemoveGroups' => [
|
||||
'sysop' => [ 'rollback' ],
|
||||
'bureaucrat' => [ 'sysop' ],
|
||||
],
|
||||
'wgGroupsAddToSelf' => [
|
||||
'sysop' => [ 'flood' ],
|
||||
],
|
||||
'wgGroupsRemoveFromSelf' => [
|
||||
'flood' => [ 'flood' ],
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* @covers User::changeableGroups
|
||||
*/
|
||||
public function testChangeableGroups() {
|
||||
$this->setMwGlobals( self::CHANGEABLE_GROUPS_TEST_CONFIG );
|
||||
$this->hideDeprecated( 'User::changeableGroups' );
|
||||
|
||||
$allGroups = User::getAllGroups();
|
||||
|
||||
$user = $this->getTestUser( [ 'doEverything' ] )->getUser();
|
||||
$changeableGroups = $user->changeableGroups();
|
||||
$this->assertGroupsEquals(
|
||||
[
|
||||
'add' => $allGroups,
|
||||
'remove' => $allGroups,
|
||||
'add-self' => [],
|
||||
'remove-self' => [],
|
||||
],
|
||||
$changeableGroups
|
||||
);
|
||||
|
||||
$user = $this->getTestUser( [ 'bureaucrat', 'sysop' ] )->getUser();
|
||||
$changeableGroups = $user->changeableGroups();
|
||||
$this->assertGroupsEquals(
|
||||
[
|
||||
'add' => [ 'bureaucrat', 'sysop', 'rollback' ],
|
||||
'remove' => [ 'sysop', 'rollback' ],
|
||||
'add-self' => [ 'flood' ],
|
||||
'remove-self' => [],
|
||||
],
|
||||
$changeableGroups
|
||||
);
|
||||
|
||||
$user = $this->getTestUser( [ 'flood' ] )->getUser();
|
||||
$changeableGroups = $user->changeableGroups();
|
||||
$this->assertGroupsEquals(
|
||||
[
|
||||
'add' => [],
|
||||
'remove' => [],
|
||||
'add-self' => [],
|
||||
'remove-self' => [ 'flood' ],
|
||||
],
|
||||
$changeableGroups
|
||||
);
|
||||
}
|
||||
|
||||
public function provideChangeableByGroup() {
|
||||
yield 'sysop' => [ 'sysop', [
|
||||
'add' => [ 'rollback' ],
|
||||
'remove' => [ 'rollback' ],
|
||||
'add-self' => [ 'flood' ],
|
||||
'remove-self' => [],
|
||||
] ];
|
||||
yield 'flood' => [ 'flood', [
|
||||
'add' => [],
|
||||
'remove' => [],
|
||||
'add-self' => [],
|
||||
'remove-self' => [ 'flood' ],
|
||||
] ];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideChangeableByGroup
|
||||
* @covers User::changeableByGroup
|
||||
* @param string $group
|
||||
* @param array $expected
|
||||
*/
|
||||
public function testChangeableByGroup( string $group, array $expected ) {
|
||||
$this->setMwGlobals( self::CHANGEABLE_GROUPS_TEST_CONFIG );
|
||||
$this->hideDeprecated( 'User::changeableByGroup' );
|
||||
$this->assertGroupsEquals( $expected, User::changeableByGroup( $group ) );
|
||||
}
|
||||
|
||||
private function assertGroupsEquals( array $expected, array $actual ) {
|
||||
// assertArrayEquals can compare without requiring the same order,
|
||||
// but the elements of an array are still required to be in the same order,
|
||||
// so just compare each element
|
||||
$this->assertArrayEquals( $expected['add'], $actual['add'] );
|
||||
$this->assertArrayEquals( $expected['remove'], $actual['remove'] );
|
||||
$this->assertArrayEquals( $expected['add-self'], $actual['add-self'] );
|
||||
$this->assertArrayEquals( $expected['remove-self'], $actual['remove-self'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers User::getName
|
||||
* @covers User::setName
|
||||
|
|
|
|||
Loading…
Reference in a new issue