10require_once __DIR__ .
'/Maintenance.php';
22 parent::__construct();
24 'Copy the data from the revision_comment_temp into the revision table'
28 'Sleep time (in seconds) between every batch. Default: 0',
44 if ( !$dbw->fieldExists(
'revision',
'rev_comment_id', __METHOD__ ) ) {
45 $this->
output(
"Run update.php to create rev_comment_id.\n" );
48 if ( !$dbw->tableExists(
'revision_comment_temp', __METHOD__ ) ) {
49 $this->
output(
"revision_comment_temp does not exist, so nothing to do.\n" );
53 $this->
output(
"Merging the revision_comment_temp table into the revision table...\n" );
56 $sleep = (int)$this->
getOption(
'sleep', 0 );
58 $res = $dbw->newSelectQueryBuilder()
59 ->select( [
'rev_id',
'revcomment_comment_id' ] )
61 ->join(
'revision_comment_temp',
null,
'rev_id=revcomment_rev' )
62 ->where( [
'rev_comment_id' => 0 ] )
66 ->caller( __METHOD__ )
69 $numRows = $res->numRows();
72 foreach ( $res as $row ) {
74 $dbw->newUpdateQueryBuilder()
75 ->update(
'revision' )
76 ->set( [
'rev_comment_id' => $row->revcomment_comment_id ] )
77 ->where( [
'rev_id' => $row->rev_id ] )
78 ->caller( __METHOD__ )->execute();
79 $updated += $dbw->affectedRows();
82 if ( $numRows < $batchSize ) {
88 $this->
output(
"... rev_id=$last, updated $updated\n" );
89 $conds = [ $dbw->expr(
'rev_id',
'>', $last ) ];
98 "Completed merge of revision_comment_temp into the revision table, "
99 .
"$updated rows updated.\n"
107require_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.