51 $batchSize = $this->getBatchSize();
54 if ( !$dbw->fieldExists(
'revision',
'rev_comment_id', __METHOD__ ) ) {
55 $this->output(
"Run update.php to create rev_comment_id.\n" );
58 if ( !$dbw->tableExists(
'revision_comment_temp', __METHOD__ ) ) {
59 $this->output(
"revision_comment_temp does not exist, so nothing to do.\n" );
63 $this->output(
"Merging the revision_comment_temp table into the revision table...\n" );
66 $sleep = (int)$this->getOption(
'sleep', 0 );
68 $res = $dbw->newSelectQueryBuilder()
69 ->select( [
'rev_id',
'revcomment_comment_id' ] )
71 ->join(
'revision_comment_temp',
null,
'rev_id=revcomment_rev' )
72 ->where( [
'rev_comment_id' => 0 ] )
76 ->caller( __METHOD__ )
79 $numRows = $res->numRows();
82 foreach ( $res as $row ) {
84 $dbw->newUpdateQueryBuilder()
85 ->update(
'revision' )
86 ->set( [
'rev_comment_id' => $row->revcomment_comment_id ] )
87 ->where( [
'rev_id' => $row->rev_id ] )
88 ->caller( __METHOD__ )->execute();
89 $updated += $dbw->affectedRows();
92 if ( $numRows < $batchSize ) {
98 $this->output(
"... rev_id=$last, updated $updated\n" );
99 $conds = [ $dbw->expr(
'rev_id',
'>', $last ) ];
102 $this->waitForReplication();
108 "Completed merge of revision_comment_temp into the revision table, "
109 .
"$updated rows updated.\n"