X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FchangePassword.php;h=316004bdf0654b530494c4fe3e176d3525c7d44c;hb=5d42fb6549adf3aa660f65a8cbabb5c3efda69fe;hp=a550d12777431c7d342d6ffde3bc277c03585289;hpb=b86ef89dd17f51841a220e8ef9b3b8b2402e2547;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/changePassword.php b/maintenance/changePassword.php index a550d12777..316004bdf0 100644 --- a/maintenance/changePassword.php +++ b/maintenance/changePassword.php @@ -41,39 +41,33 @@ class ChangePassword extends Maintenance { } public function execute() { - global $wgDisableAuthManager; - if ( $this->hasOption( "user" ) ) { $user = User::newFromName( $this->getOption( 'user' ) ); } elseif ( $this->hasOption( "userid" ) ) { $user = User::newFromId( $this->getOption( 'userid' ) ); } else { - $this->error( "A \"user\" or \"userid\" must be set to change the password for", true ); + $this->fatalError( "A \"user\" or \"userid\" must be set to change the password for" ); } if ( !$user || !$user->getId() ) { - $this->error( "No such user: " . $this->getOption( 'user' ), true ); + $this->fatalError( "No such user: " . $this->getOption( 'user' ) ); } $password = $this->getOption( 'password' ); try { - if ( $wgDisableAuthManager ) { - $user->setPassword( $password ); - } else { - $status = $user->changeAuthenticationData( [ - 'username' => $user->getName(), - 'password' => $password, - 'retype' => $password, - ] ); - if ( !$status->isGood() ) { - throw new PasswordError( $status->getWikiText( null, null, 'en' ) ); - } + $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 ) { - $this->error( $pwe->getText(), true ); + $this->fatalError( $pwe->getText() ); } } } -$maintClass = "ChangePassword"; +$maintClass = ChangePassword::class; require_once RUN_MAINTENANCE_IF_MAIN;