X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FcreateAndPromote.php;h=93614e0a77b7cd1f4cee30907e9ae67f712682df;hb=291a9237dcd761bc250bfad9a9bf0cd04be071a2;hp=d3efca6f42a7f16ea9fd2707e850c494567ed58e;hpb=77e3624caba072521fbc1826af2d47f9b29f4032;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/createAndPromote.php b/maintenance/createAndPromote.php index d3efca6f42..93614e0a77 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(); @@ -66,7 +66,7 @@ class CreateAndPromote extends Maintenance { $this->fatalError( "invalid username." ); } - $exists = ( 0 !== $user->idForName() ); + $exists = ( $user->idForName() !== 0 ); if ( $exists && !$force ) { $this->fatalError( "Account exists. Perhaps you want the --force option?" ); @@ -112,9 +112,16 @@ class CreateAndPromote extends Maintenance { } if ( !$exists ) { - # Insert the account into the database - $user->addToDatabase(); - $user->saveSettings(); + // Create the user via AuthManager as there may be various side + // effects that are perfomed by the configured AuthManager chain. + $status = MediaWiki\Auth\AuthManager::singleton()->autoCreateUser( + $user, + MediaWiki\Auth\AuthManager::AUTOCREATE_SOURCE_MAINT, + false + ); + if ( !$status->isGood() ) { + $this->fatalError( $status->getWikiText( null, null, 'en' ) ); + } } if ( $password ) {