Merge "Migrate various callers away from wfWikiId() to WikiMap"
[lhc/web/wiklou.git] / maintenance / createAndPromote.php
index 24ab3d2..da9b4d6 100644 (file)
@@ -103,18 +103,26 @@ class CreateAndPromote extends Maintenance {
 
                        return;
                } elseif ( count( $promotions ) !== 0 ) {
+                       $dbDomain = WikiMap::getCurrentWikiDbDomain()->getId();
                        $promoText = "User:{$username} into " . implode( ', ', $promotions ) . "...\n";
                        if ( $exists ) {
-                               $this->output( wfWikiID() . ": Promoting $promoText" );
+                               $this->output( "$dbDomain: Promoting $promoText" );
                        } else {
-                               $this->output( wfWikiID() . ": Creating and promoting $promoText" );
+                               $this->output( "$dbDomain: Creating and promoting $promoText" );
                        }
                }
 
                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 ) {
@@ -142,7 +150,7 @@ class CreateAndPromote extends Maintenance {
 
                if ( !$exists ) {
                        # Increment site_stats.ss_users
-                       $ssu = new SiteStatsUpdate( 0, 0, 0, 0, 1 );
+                       $ssu = SiteStatsUpdate::factory( [ 'users' => 1 ] );
                        $ssu->doUpdate();
                }