* @license GPL-2.0-or-later
*/
-use Wikimedia\Rdbms\IDatabase;
-
require_once __DIR__ . '/Maintenance.php';
/**
* @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__ );
if ( $total ) {
# Reassign edits
$this->output( "\nReassigning current edits..." );
- if ( $wgActorTableSchemaMigrationStage < MIGRATION_NEW ) {
- $dbw->update(
- 'revision',
- [
- 'rev_user' => $to->getId(),
- 'rev_user_text' =>
- $wgActorTableSchemaMigrationStage <= MIGRATION_WRITE_BOTH ? $to->getName() : ''
- ],
- $from->isLoggedIn()
- ? [ 'rev_user' => $from->getId() ] : [ 'rev_user_text' => $from->getName() ],
- __METHOD__
- );
- }
- if ( $wgActorTableSchemaMigrationStage > MIGRATION_OLD ) {
- $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" );
}
return (int)$total;
}
- /**
- * Return user specifications
- * 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 < MIGRATION_NEW ) {
- $ret += [
- $idfield => $user->getId(),
- $utfield => $wgActorTableSchemaMigrationStage <= MIGRATION_WRITE_BOTH ? $user->getName() : '',
- ];
- }
- if ( $wgActorTableSchemaMigrationStage > MIGRATION_OLD ) {
- $ret += [ $acfield => $user->getActorId( $dbw ) ];
- }
- return $ret;
- }
-
/**
* Initialise the user object
*