Convert PasswordReset to using MapCacheLRU
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 11 Jul 2018 13:08:08 +0000 (14:08 +0100)
committerKrinkle <krinklemail@gmail.com>
Sat, 14 Jul 2018 01:31:54 +0000 (01:31 +0000)
Avoid NULL user name that caused test failures

Change-Id: Ifc3b19cc7e172300123e7d2c7153b4357917ca74

includes/user/PasswordReset.php
tests/phpunit/includes/user/PasswordResetTest.php

index e7825e4..39c0c1b 100644 (file)
@@ -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' );
        }
 
index 1f578ab..4978b72 100644 (file)
@@ -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();