$this->addOption( "user", "The username to operate on", false, true );
$this->addOption( "userid", "The user id to operate on", false, true );
$this->addOption( "password", "The password to use", true, true );
- $this->mDescription = "Change a user's password";
+ $this->addDescription( "Change a user's password" );
}
public function execute() {
if ( !$user || !$user->getId() ) {
$this->error( "No such user: " . $this->getOption( 'user' ), true );
}
+ $password = $this->getOption( 'password' );
try {
- $user->setPassword( $this->getOption( 'password' ) );
+ $status = $user->changeAuthenticationData( [
+ 'username' => $user->getName(),
+ 'password' => $password,
+ 'retype' => $password,
+ ] );
+ if ( !$status->isGood() ) {
+ throw new PasswordError( $status->getWikiText( null, null, 'en' ) );
+ }
$user->saveSettings();
$this->output( "Password set for " . $user->getName() . "\n" );
} catch ( PasswordError $pwe ) {