3 require_once __DIR__
. '/Maintenance.php';
6 * Maintenance script that cleans up cases where rev_page and revactor_page
7 * became desynced, e.g. from T232464.
12 class CleanupRevActorPage
extends LoggedUpdateMaintenance
{
14 public function __construct() {
15 parent
::__construct();
16 $this->addDescription(
17 'Resyncs revactor_page with rev_page when they differ, e.g. from T232464.'
19 $this->setBatchSize( 1000 );
22 protected function getUpdateKey() {
26 protected function doDBUpdates() {
27 $dbw = $this->getDB( DB_MASTER
);
28 $max = $dbw->selectField( 'revision', 'MAX(rev_id)', '', __METHOD__
);
29 $batchSize = $this->mBatchSize
;
31 $this->output( "Resyncing revactor_page with rev_page...\n" );
34 for ( $start = 1; $start <= $max; $start +
= $batchSize ) {
35 $end = $start +
$batchSize - 1;
36 $this->output( "... rev_id $start - $end, $count changed\n" );
38 // Fetch the rows needing update
40 [ 'revision', 'revision_actor_temp' ],
41 [ 'rev_id', 'rev_page' ],
43 'rev_page != revactor_page',
49 [ 'revision_actor_temp' => [ 'JOIN', 'rev_id = revactor_rev' ] ]
52 if ( !$res->numRows() ) {
56 // Update the existing rows
57 foreach ( $res as $row ) {
59 'revision_actor_temp',
60 [ 'revactor_page' => $row->rev_page
],
61 [ 'revactor_rev' => $row->rev_id
],
64 $count +
= $dbw->affectedRows();
70 $this->output( "Completed resync, $count row(s) updated\n" );
76 $maintClass = CleanupRevActorPage
::class;
77 require_once RUN_MAINTENANCE_IF_MAIN
;