6require_once __DIR__ .
'/Maintenance.php';
18 parent::__construct();
20 'Copy the data from the revision_actor_temp into the revision table'
24 'Sleep time (in seconds) between every batch. Default: 0',
28 $this->
addOption(
'start',
'Start after this rev_id',
false,
true );
39 if ( !$dbw->fieldExists(
'revision',
'rev_actor', __METHOD__ ) ) {
40 $this->
output(
"Run update.php to create rev_actor.\n" );
43 if ( !$dbw->tableExists(
'revision_actor_temp', __METHOD__ ) ) {
44 $this->
output(
"revision_actor_temp does not exist, so nothing to do.\n" );
48 $this->
output(
"Merging the revision_actor_temp table into the revision table...\n" );
51 $start = (int)$this->
getOption(
'start', 0 );
53 $conds[] = $dbw->expr(
'rev_id',
'>=', $start );
56 $res = $dbw->newSelectQueryBuilder()
57 ->select( [
'rev_id',
'rev_actor',
'revactor_actor' ] )
59 ->join(
'revision_actor_temp',
null,
'rev_id=revactor_rev' )
63 ->caller( __METHOD__ )
66 $numRows = $res->numRows();
69 foreach ( $res as $row ) {
71 if ( !$row->rev_actor ) {
72 $dbw->newUpdateQueryBuilder()
73 ->update(
'revision' )
74 ->set( [
'rev_actor' => $row->revactor_actor ] )
75 ->where( [
'rev_id' => $row->rev_id ] )
76 ->caller( __METHOD__ )->execute();
77 $updated += $dbw->affectedRows();
78 } elseif ( $row->rev_actor !== $row->revactor_actor ) {
80 "Revision ID $row->rev_id has rev_actor = $row->rev_actor and "
81 .
"revactor_actor = $row->revactor_actor. Ignoring the latter."
86 if ( $numRows < $batchSize ) {
92 $this->
output(
"... rev_id=$last, updated $updated\n" );
93 $conds = [ $dbw->expr(
'rev_id',
'>', $last ) ];
97 $sleep = (int)$this->
getOption(
'sleep', 0 );
104 "Completed merge of revision_actor into the revision table, "
105 .
"$updated rows updated.\n"
115require_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.
error( $err, $die=0)
Throw an error to the user.
addDescription( $text)
Set the description text.
Maintenance script that merges the revision_actor_temp table into the revision table.
__construct()
Default constructor.
getUpdateKey()
Get the update key name to go in the update log table.
doDBUpdates()
Do the actual work.