Merge "Make DBAccessBase use DBConnRef, rename $wiki, and hide getLoadBalancer()"
[lhc/web/wiklou.git] / maintenance / reassignEdits.php
index d90a4a7..54f1862 100644 (file)
@@ -76,7 +76,7 @@ class ReassignEdits extends Maintenance {
         * @return int Number of entries changed, or that would be changed
         */
        private function doReassignEdits( &$from, &$to, $rc = false, $report = false ) {
-               global $wgActorTableSchemaMigrationStage;
+               $actorTableSchemaMigrationStage = $this->getConfig()->get( 'ActorTableSchemaMigrationStage' );
 
                $dbw = $this->getDB( DB_MASTER );
                $this->beginTransaction( $dbw, __METHOD__ );
@@ -136,20 +136,19 @@ class ReassignEdits extends Maintenance {
                        if ( $total ) {
                                # Reassign edits
                                $this->output( "\nReassigning current edits..." );
-                               if ( $wgActorTableSchemaMigrationStage < MIGRATION_NEW ) {
+                               if ( $actorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD ) {
                                        $dbw->update(
                                                'revision',
                                                [
                                                        'rev_user' => $to->getId(),
-                                                       'rev_user_text' =>
-                                                               $wgActorTableSchemaMigrationStage <= MIGRATION_WRITE_BOTH ? $to->getName() : ''
+                                                       'rev_user_text' => $to->getName(),
                                                ],
                                                $from->isLoggedIn()
                                                        ? [ 'rev_user' => $from->getId() ] : [ 'rev_user_text' => $from->getName() ],
                                                __METHOD__
                                        );
                                }
-                               if ( $wgActorTableSchemaMigrationStage > MIGRATION_OLD ) {
+                               if ( $actorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) {
                                        $dbw->update(
                                                'revision_actor_temp',
                                                [ 'revactor_actor' => $to->getActorId( $dbw ) ],
@@ -179,7 +178,7 @@ class ReassignEdits extends Maintenance {
        }
 
        /**
-        * Return user specifications
+        * Return user specifications for an UPDATE
         * i.e. user => id, user_text => text
         *
         * @param IDatabase $dbw Database handle
@@ -190,16 +189,16 @@ class ReassignEdits extends Maintenance {
         * @return array
         */
        private function userSpecification( IDatabase $dbw, &$user, $idfield, $utfield, $acfield ) {
-               global $wgActorTableSchemaMigrationStage;
+               $actorTableSchemaMigrationStage = $this->getConfig()->get( 'ActorTableSchemaMigrationStage' );
 
                $ret = [];
-               if ( $wgActorTableSchemaMigrationStage < MIGRATION_NEW ) {
+               if ( $actorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD ) {
                        $ret += [
                                $idfield => $user->getId(),
-                               $utfield => $wgActorTableSchemaMigrationStage <= MIGRATION_WRITE_BOTH ? $user->getName() : '',
+                               $utfield => $user->getName(),
                        ];
                }
-               if ( $wgActorTableSchemaMigrationStage > MIGRATION_OLD ) {
+               if ( $actorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) {
                        $ret += [ $acfield => $user->getActorId( $dbw ) ];
                }
                return $ret;