From: Aaron Schulz Date: Wed, 11 Jul 2018 13:08:08 +0000 (+0100) Subject: Convert PasswordReset to using MapCacheLRU X-Git-Tag: 1.34.0-rc.0~4770 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmes_infos.php?a=commitdiff_plain;h=563026acf45526a3dc3761750fdebe006c85ba75;p=lhc%2Fweb%2Fwiklou.git Convert PasswordReset to using MapCacheLRU Avoid NULL user name that caused test failures Change-Id: Ifc3b19cc7e172300123e7d2c7153b4357917ca74 --- diff --git a/includes/user/PasswordReset.php b/includes/user/PasswordReset.php index e7825e4239..39c0c1baf4 100644 --- a/includes/user/PasswordReset.php +++ b/includes/user/PasswordReset.php @@ -46,14 +46,14 @@ class PasswordReset implements LoggerAwareInterface { /** * In-process cache for isAllowed lookups, by username. * Contains a StatusValue object - * @var HashBagOStuff + * @var MapCacheLRU */ private $permissionCache; public function __construct( Config $config, AuthManager $authManager ) { $this->config = $config; $this->authManager = $authManager; - $this->permissionCache = new HashBagOStuff( [ 'maxKeys' => 1 ] ); + $this->permissionCache = new MapCacheLRU( 1 ); $this->logger = LoggerFactory::getInstance( 'authentication' ); } diff --git a/tests/phpunit/includes/user/PasswordResetTest.php b/tests/phpunit/includes/user/PasswordResetTest.php index 1f578ab0c8..4978b7290a 100644 --- a/tests/phpunit/includes/user/PasswordResetTest.php +++ b/tests/phpunit/includes/user/PasswordResetTest.php @@ -168,6 +168,7 @@ class PasswordResetTest extends MediaWikiTestCase { $performingUser = $this->getMockBuilder( User::class )->getMock(); $performingUser->expects( $this->any() )->method( 'getRequest' )->willReturn( $request ); $performingUser->expects( $this->any() )->method( 'isAllowed' )->willReturn( true ); + $performingUser->expects( $this->any() )->method( 'getName' )->willReturn( 'Performer' ); $targetUser1 = $this->getMockBuilder( User::class )->getMock(); $targetUser2 = $this->getMockBuilder( User::class )->getMock();