From: Gergő Tisza Date: Mon, 8 Apr 2019 22:19:07 +0000 (-0700) Subject: Improve changePassword.php error handling X-Git-Tag: 1.34.0-rc.0~1545^2 X-Git-Url: http://git.cyclocoop.org/%7B%7B%20url_for%28%27admin_vote_add%27%29%20%7D%7D?a=commitdiff_plain;h=1968af17edc1c0874a82800a7498f87439e0523e;p=lhc%2Fweb%2Fwiklou.git Improve changePassword.php error handling * User::changeAuthenticationData does not throw PasswordError * passwords are not stored in User so there's no point in saving it Bug: T219689 Change-Id: I2cef889523903fb8c5f091f63482970ea212446c --- diff --git a/maintenance/changePassword.php b/maintenance/changePassword.php index 316004bdf0..e7df448f7a 100644 --- a/maintenance/changePassword.php +++ b/maintenance/changePassword.php @@ -52,19 +52,15 @@ class ChangePassword extends Maintenance { $this->fatalError( "No such user: " . $this->getOption( 'user' ) ); } $password = $this->getOption( 'password' ); - try { - $status = $user->changeAuthenticationData( [ - 'username' => $user->getName(), - 'password' => $password, - 'retype' => $password, - ] ); - if ( !$status->isGood() ) { - throw new PasswordError( $status->getWikiText( null, null, 'en' ) ); - } - $user->saveSettings(); + $status = $user->changeAuthenticationData( [ + 'username' => $user->getName(), + 'password' => $password, + 'retype' => $password, + ] ); + if ( $status->isGood() ) { $this->output( "Password set for " . $user->getName() . "\n" ); - } catch ( PasswordError $pwe ) { - $this->fatalError( $pwe->getText() ); + } else { + $this->fatalError( $status->getWikiText( null, null, 'en' ) ); } } }