$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' ) );
}
}
}