X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FreassignEdits.php;h=f3b856cbcfe0cfca2586b2f3123128861ba0aeaf;hb=520b167979260edf2cee41842e526ec985c37f92;hp=98025d1d90eb5ab70ae3400fa1bb077a49cbeca3;hpb=c69bf3bc87bacc84da42f95781e950e4bc9d48d1;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/reassignEdits.php b/maintenance/reassignEdits.php index 98025d1d90..f3b856cbcf 100644 --- a/maintenance/reassignEdits.php +++ b/maintenance/reassignEdits.php @@ -23,8 +23,6 @@ * @license GPL-2.0-or-later */ -use Wikimedia\Rdbms\IDatabase; - require_once __DIR__ . '/Maintenance.php'; /** @@ -76,8 +74,6 @@ 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; - $dbw = $this->getDB( DB_MASTER ); $this->beginTransaction( $dbw, __METHOD__ ); @@ -136,36 +132,22 @@ class ReassignEdits extends Maintenance { if ( $total ) { # Reassign edits $this->output( "\nReassigning current edits..." ); - if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD ) { - $dbw->update( - 'revision', - [ - 'rev_user' => $to->getId(), - 'rev_user_text' => $to->getName(), - ], - $from->isLoggedIn() - ? [ 'rev_user' => $from->getId() ] : [ 'rev_user_text' => $from->getName() ], - __METHOD__ - ); - } - if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) { - $dbw->update( - 'revision_actor_temp', - [ 'revactor_actor' => $to->getActorId( $dbw ) ], - [ 'revactor_actor' => $from->getActorId() ], - __METHOD__ - ); - } + $dbw->update( + 'revision_actor_temp', + [ 'revactor_actor' => $to->getActorId( $dbw ) ], + [ 'revactor_actor' => $from->getActorId() ], + __METHOD__ + ); $this->output( "done.\nReassigning deleted edits..." ); $dbw->update( 'archive', - $this->userSpecification( $dbw, $to, 'ar_user', 'ar_user_text', 'ar_actor' ), + [ 'ar_actor' => $to->getActorId( $dbw ) ], [ $arQueryInfo['conds'] ], __METHOD__ ); $this->output( "done.\n" ); # Update recent changes if required if ( $rc ) { $this->output( "Updating recent changes..." ); $dbw->update( 'recentchanges', - $this->userSpecification( $dbw, $to, 'rc_user', 'rc_user_text', 'rc_actor' ), + [ 'rc_actor' => $to->getActorId( $dbw ) ], [ $rcQueryInfo['conds'] ], __METHOD__ ); $this->output( "done.\n" ); } @@ -177,33 +159,6 @@ class ReassignEdits extends Maintenance { return (int)$total; } - /** - * Return user specifications for an UPDATE - * i.e. user => id, user_text => text - * - * @param IDatabase $dbw Database handle - * @param User $user User for the spec - * @param string $idfield Field name containing the identifier - * @param string $utfield Field name containing the user text - * @param string $acfield Field name containing the actor ID - * @return array - */ - private function userSpecification( IDatabase $dbw, &$user, $idfield, $utfield, $acfield ) { - global $wgActorTableSchemaMigrationStage; - - $ret = []; - if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD ) { - $ret += [ - $idfield => $user->getId(), - $utfield => $user->getName(), - ]; - } - if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) { - $ret += [ $acfield => $user->getActorId( $dbw ) ]; - } - return $ret; - } - /** * Initialise the user object *