24require_once __DIR__ .
'/Maintenance.php';
36 parent::__construct();
38 'Copy the data from the revision_comment_temp into the revision table'
42 'Sleep time (in seconds) between every batch. Default: 0',
58 if ( !$dbw->fieldExists(
'revision',
'rev_comment_id', __METHOD__ ) ) {
59 $this->
output(
"Run update.php to create rev_comment_id.\n" );
62 if ( !$dbw->tableExists(
'revision_comment_temp', __METHOD__ ) ) {
63 $this->
output(
"revision_comment_temp does not exist, so nothing to do.\n" );
67 $this->
output(
"Merging the revision_comment_temp table into the revision table...\n" );
70 $sleep = (int)$this->
getOption(
'sleep', 0 );
72 $res = $dbw->newSelectQueryBuilder()
73 ->select( [
'rev_id',
'revcomment_comment_id' ] )
75 ->join(
'revision_comment_temp',
null,
'rev_id=revcomment_rev' )
76 ->where( [
'rev_comment_id' => 0 ] )
80 ->caller( __METHOD__ )
83 $numRows = $res->numRows();
86 foreach ( $res as $row ) {
88 $dbw->newUpdateQueryBuilder()
89 ->update(
'revision' )
90 ->set( [
'rev_comment_id' => $row->revcomment_comment_id ] )
91 ->where( [
'rev_id' => $row->rev_id ] )
92 ->caller( __METHOD__ )->execute();
93 $updated += $dbw->affectedRows();
96 if ( $numRows < $batchSize ) {
102 $this->
output(
"... rev_id=$last, updated $updated\n" );
103 $conds = [ $dbw->expr(
'rev_id',
'>', $last ) ];
112 "Completed merge of revision_comment_temp into the revision table, "
113 .
"$updated rows updated.\n"
121require_once RUN_MAINTENANCE_IF_MAIN;
Class for scripts that perform database maintenance and want to log the update in updatelog so we can...
getBatchSize()
Returns batch size.
output( $out, $channel=null)
Throw some output to the user.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getDB( $db, $groups=[], $dbDomain=false)
Returns a database to be used by current maintenance script.
waitForReplication()
Wait for replica DB servers to catch up.
getOption( $name, $default=null)
Get an option, or return the default.
addDescription( $text)
Set the description text.