MediaWiki REL1_34
cleanupRevActorPage.php
Go to the documentation of this file.
1<?php
2
3require_once __DIR__ . '/Maintenance.php';
4
13
14 public function __construct() {
15 parent::__construct();
16 $this->addDescription(
17 'Resyncs revactor_page with rev_page when they differ, e.g. from T232464.'
18 );
19 $this->setBatchSize( 1000 );
20 }
21
22 protected function getUpdateKey() {
23 return __CLASS__;
24 }
25
26 protected function doDBUpdates() {
27 $dbw = $this->getDB( DB_MASTER );
28 $max = $dbw->selectField( 'revision', 'MAX(rev_id)', '', __METHOD__ );
29 $batchSize = $this->mBatchSize;
30
31 $this->output( "Resyncing revactor_page with rev_page...\n" );
32
33 $count = 0;
34 for ( $start = 1; $start <= $max; $start += $batchSize ) {
35 $end = $start + $batchSize - 1;
36 $this->output( "... rev_id $start - $end, $count changed\n" );
37
38 // Fetch the rows needing update
39 $res = $dbw->select(
40 [ 'revision', 'revision_actor_temp' ],
41 [ 'rev_id', 'rev_page' ],
42 [
43 'rev_page != revactor_page',
44 "rev_id >= $start",
45 "rev_id <= $end",
46 ],
47 __METHOD__,
48 [],
49 [ 'revision_actor_temp' => [ 'JOIN', 'rev_id = revactor_rev' ] ]
50 );
51
52 if ( !$res->numRows() ) {
53 continue;
54 }
55
56 // Update the existing rows
57 foreach ( $res as $row ) {
58 $dbw->update(
59 'revision_actor_temp',
60 [ 'revactor_page' => $row->rev_page ],
61 [ 'revactor_rev' => $row->rev_id ],
62 __METHOD__
63 );
64 $count += $dbw->affectedRows();
65 }
66
68 }
69
70 $this->output( "Completed resync, $count row(s) updated\n" );
71
72 return true;
73 }
74}
75
76$maintClass = CleanupRevActorPage::class;
77require_once RUN_MAINTENANCE_IF_MAIN;
getDB()
wfWaitForSlaves( $ifWritesSince=null, $wiki=false, $cluster=false, $timeout=null)
Waits for the replica DBs to catch up to the master position.
const RUN_MAINTENANCE_IF_MAIN
Maintenance script that cleans up cases where rev_page and revactor_page became desynced,...
doDBUpdates()
Do the actual work.
__construct()
Default constructor.
getUpdateKey()
Get the update key name to go in the update log table.
Class for scripts that perform database maintenance and want to log the update in updatelog so we can...
int $mBatchSize
Batch size.
output( $out, $channel=null)
Throw some output to the user.
addDescription( $text)
Set the description text.
setBatchSize( $s=0)
Set the batch size.
const DB_MASTER
Definition defines.php:26