34 $batchSize = $this->getBatchSize();
37 if ( !$dbw->fieldExists(
'revision',
'rev_actor', __METHOD__ ) ) {
38 $this->output(
"Run update.php to create rev_actor.\n" );
41 if ( !$dbw->tableExists(
'revision_actor_temp', __METHOD__ ) ) {
42 $this->output(
"revision_actor_temp does not exist, so nothing to do.\n" );
46 $this->output(
"Merging the revision_actor_temp table into the revision table...\n" );
49 $start = (int)$this->getOption(
'start', 0 );
51 $conds[] = $dbw->expr(
'rev_id',
'>=', $start );
54 $res = $dbw->newSelectQueryBuilder()
55 ->select( [
'rev_id',
'rev_actor',
'revactor_actor' ] )
57 ->join(
'revision_actor_temp',
null,
'rev_id=revactor_rev' )
61 ->caller( __METHOD__ )
64 $numRows = $res->numRows();
67 foreach ( $res as $row ) {
69 if ( !$row->rev_actor ) {
70 $dbw->newUpdateQueryBuilder()
71 ->update(
'revision' )
72 ->set( [
'rev_actor' => $row->revactor_actor ] )
73 ->where( [
'rev_id' => $row->rev_id ] )
74 ->caller( __METHOD__ )->execute();
75 $updated += $dbw->affectedRows();
76 } elseif ( $row->rev_actor !== $row->revactor_actor ) {
78 "Revision ID $row->rev_id has rev_actor = $row->rev_actor and "
79 .
"revactor_actor = $row->revactor_actor. Ignoring the latter."
84 if ( $numRows < $batchSize ) {
90 $this->output(
"... rev_id=$last, updated $updated\n" );
91 $conds = [ $dbw->expr(
'rev_id',
'>', $last ) ];
94 $this->waitForReplication();
95 $sleep = (int)$this->getOption(
'sleep', 0 );
102 "Completed merge of revision_actor into the revision table, "
103 .
"$updated rows updated.\n"