From 846d84fa1827c3c1672b78fd07aadd6068e8fabc Mon Sep 17 00:00:00 2001 From: Thalia Date: Tue, 2 Apr 2019 11:00:49 +0100 Subject: [PATCH] Set default for Block::appliesToPasswordReset to true Follow-up to Ia3f46aba. Before that patch, the default case for whether a block blocks password reset was true. Bug: T218905 Change-Id: I86cb381762890abddcf32f4f7199799391cc6dfb --- includes/Block.php | 4 ++-- tests/phpunit/includes/user/PasswordResetTest.php | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/includes/Block.php b/includes/Block.php index 58ef4488dd..c6b948239c 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -2146,7 +2146,7 @@ class Block { * Check if the block prevents a user from resetting their password * * @since 1.33 - * @return bool|null The block blocks password reset + * @return bool The block blocks password reset */ public function appliesToPasswordReset() { switch ( $this->getSystemBlockType() ) { @@ -2159,7 +2159,7 @@ class Block { case 'wgSoftBlockRanges': return false; default: - return false; + return true; } } diff --git a/tests/phpunit/includes/user/PasswordResetTest.php b/tests/phpunit/includes/user/PasswordResetTest.php index 4978b7290a..e8334d6bf9 100644 --- a/tests/phpunit/includes/user/PasswordResetTest.php +++ b/tests/phpunit/includes/user/PasswordResetTest.php @@ -133,6 +133,15 @@ class PasswordResetTest extends MediaWikiTestCase { 'globalBlock' => null, 'isAllowed' => true, ], + 'blocked with an unknown system block type' => [ + 'passwordResetRoutes' => [ 'username' => true ], + 'enableEmail' => true, + 'allowsAuthenticationDataChange' => true, + 'canEditPrivate' => true, + 'block' => new Block( [ 'systemBlock' => 'unknown' ] ), + 'globalBlock' => null, + 'isAllowed' => false, + ], 'all OK' => [ 'passwordResetRoutes' => [ 'username' => true ], 'enableEmail' => true, -- 2.20.1