X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FcreateAndPromote.php;h=93614e0a77b7cd1f4cee30907e9ae67f712682df;hb=178b7ad6a4cedc42e69c5fe00e55b63621bd0e47;hp=2072d7b54d6062ae60e43569c4ad0bac7704f844;hpb=fd08137ebf8b34cb1a9711c34d6c4d0357aea5b7;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/createAndPromote.php b/maintenance/createAndPromote.php index 2072d7b54d..93614e0a77 100644 --- a/maintenance/createAndPromote.php +++ b/maintenance/createAndPromote.php @@ -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 ) {