X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FcreateAndPromote.php;h=24ab3d21fc72a1cb8c1e7b3e86365b63e5c5c105;hb=0770f85a0a293e6c7af6f1d3d3a1dbd2d13c1e09;hp=3591b9ce2456f0728c3c058571e88120c2b327d3;hpb=46272366d14254e0917a9de8688a7627354f4bdb;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/createAndPromote.php b/maintenance/createAndPromote.php index 3591b9ce24..24ab3d21fc 100644 --- a/maintenance/createAndPromote.php +++ b/maintenance/createAndPromote.php @@ -31,7 +31,7 @@ require_once __DIR__ . '/Maintenance.php'; * @ingroup Maintenance */ class CreateAndPromote extends Maintenance { - private static $permitRoles = [ 'sysop', 'bureaucrat', 'bot' ]; + private static $permitRoles = [ 'sysop', 'bureaucrat', 'interface-admin', 'bot' ]; public function __construct() { parent::__construct(); @@ -56,8 +56,6 @@ class CreateAndPromote extends Maintenance { } public function execute() { - global $wgDisableAuthManager; - $username = $this->getArg( 0 ); $password = $this->getArg( 1 ); $force = $this->hasOption( 'force' ); @@ -65,15 +63,15 @@ class CreateAndPromote extends Maintenance { $user = User::newFromName( $username ); if ( !is_object( $user ) ) { - $this->error( "invalid username.", true ); + $this->fatalError( "invalid username." ); } - $exists = ( 0 !== $user->idForName() ); + $exists = ( $user->idForName() !== 0 ); if ( $exists && !$force ) { - $this->error( "Account exists. Perhaps you want the --force option?", true ); + $this->fatalError( "Account exists. Perhaps you want the --force option?" ); } elseif ( !$exists && !$password ) { - $this->error( "Argument required!", false ); + $this->error( "Argument required!" ); $this->maybeHelp( true ); } elseif ( $exists ) { $inGroups = $user->getGroups(); @@ -122,24 +120,20 @@ class CreateAndPromote extends Maintenance { if ( $password ) { # Try to set the 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' ) ); } if ( $exists ) { $this->output( "Password set.\n" ); $user->saveSettings(); } } catch ( PasswordError $pwe ) { - $this->error( $pwe->getText(), true ); + $this->fatalError( $pwe->getText() ); } } @@ -156,5 +150,5 @@ class CreateAndPromote extends Maintenance { } } -$maintClass = "CreateAndPromote"; +$maintClass = CreateAndPromote::class; require_once RUN_MAINTENANCE_IF_MAIN;