Set default for Block::appliesToPasswordReset to true
authorThalia <thalia.e.chan@googlemail.com>
Tue, 2 Apr 2019 10:00:49 +0000 (11:00 +0100)
committerThalia <thalia.e.chan@googlemail.com>
Tue, 2 Apr 2019 13:43:09 +0000 (14:43 +0100)
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
tests/phpunit/includes/user/PasswordResetTest.php

index 58ef448..c6b9482 100644 (file)
@@ -2146,7 +2146,7 @@ class Block {
         * Check if the block prevents a user from resetting their password
         *
         * @since 1.33
         * 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() ) {
         */
        public function appliesToPasswordReset() {
                switch ( $this->getSystemBlockType() ) {
@@ -2159,7 +2159,7 @@ class Block {
                        case 'wgSoftBlockRanges':
                                return false;
                        default:
                        case 'wgSoftBlockRanges':
                                return false;
                        default:
-                               return false;
+                               return true;
                }
        }
 
                }
        }
 
index 4978b72..e8334d6 100644 (file)
@@ -133,6 +133,15 @@ class PasswordResetTest extends MediaWikiTestCase {
                                'globalBlock' => null,
                                'isAllowed' => true,
                        ],
                                '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,
                        'all OK' => [
                                'passwordResetRoutes' => [ 'username' => true ],
                                'enableEmail' => true,