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',
56 if ( !$dbw->fieldExists(
'revision',
'rev_comment_id', __METHOD__ ) ) {
57 $this->
output(
"Run update.php to create rev_comment_id.\n" );
60 if ( !$dbw->tableExists(
'revision_comment_temp', __METHOD__ ) ) {
61 $this->
output(
"revision_comment_temp does not exist, so nothing to do.\n" );
65 $this->
output(
"Merging the revision_comment_temp table into the revision table...\n" );
68 $sleep = (int)$this->
getOption(
'sleep', 0 );
70 $res = $dbw->newSelectQueryBuilder()
71 ->select( [
'rev_id',
'revcomment_comment_id' ] )
73 ->join(
'revision_comment_temp',
null,
'rev_id=revcomment_rev' )
74 ->where( [
'rev_comment_id' => 0 ] )
78 ->caller( __METHOD__ )
81 $numRows = $res->numRows();
84 foreach ( $res as $row ) {
86 $dbw->newUpdateQueryBuilder()
87 ->update(
'revision' )
88 ->set( [
'rev_comment_id' => $row->revcomment_comment_id ] )
89 ->where( [
'rev_id' => $row->rev_id ] )
90 ->caller( __METHOD__ )->execute();
91 $updated += $dbw->affectedRows();
94 if ( $numRows < $batchSize ) {
100 $this->
output(
"... rev_id=$last, updated $updated\n" );
101 $conds = [ $dbw->expr(
'rev_id',
'>', $last ) ];
110 "Completed merge of revision_comment_temp into the revision table, "
111 .
"$updated rows updated.\n"
119require_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.