From 563026acf45526a3dc3761750fdebe006c85ba75 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 11 Jul 2018 14:08:08 +0100 Subject: [PATCH] Convert PasswordReset to using MapCacheLRU Avoid NULL user name that caused test failures Change-Id: Ifc3b19cc7e172300123e7d2c7153b4357917ca74 --- includes/user/PasswordReset.php | 4 ++-- tests/phpunit/includes/user/PasswordResetTest.php | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) 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(); -- 2.20.1