From 1968af17edc1c0874a82800a7498f87439e0523e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gerg=C5=91=20Tisza?= Date: Mon, 8 Apr 2019 15:19:07 -0700 Subject: [PATCH] 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 --- maintenance/changePassword.php | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) 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' ) ); } } } -- 2.20.1