MediaWiki REL1_34
cleanupArchiveUserText.php
Go to the documentation of this file.
1<?php
2
3$IP = getenv( 'MW_INSTALL_PATH' );
4if ( $IP === false ) {
5 $IP = __DIR__ . '/../../..';
6}
7
8require_once "$IP/maintenance/Maintenance.php";
9
14 public function __construct() {
15 parent::__construct();
16 $this->addDescription( 'Update the archive table where users were ' .
17 'previously renamed, but their archive contributions were not' );
18
19 $this->requireExtension( 'Renameuser' );
20 }
21
22 public function execute() {
24 $this->output( "archive.ar_user_text is no longer used.\n" );
25 return;
26 }
27
28 $dbw = wfGetDB( DB_MASTER );
29 do {
30 $res = $dbw->select(
31 [ 'archive', 'user' ],
32 [ 'DISTINCT ar_user_text', 'user_name', 'ar_user' ],
33 [
34 'ar_user_text <> user_name',
35 'ar_user = user_id',
36 ],
37 __METHOD__,
38 [ 'LIMIT' => 50 ]
39 );
40 $results = 0;
41 foreach ( $res as $row ) {
42 $results++;
43 $this->output( "User:{$row->ar_user_text} => User:{$row->user_name} " );
44 $dbw->update(
45 'archive',
46 [ 'ar_user_text' => $row->user_name ],
47 [
48 'ar_user_text' => $row->ar_user_text,
49 'ar_user' => $row->ar_user,
50 ],
51 __METHOD__,
52 [ 'LIMIT' => 50 ]
53 );
54 $affected = $dbw->affectedRows();
55 $this->output( "$affected rows\n" );
57 }
58 } while ( $results === 50 );
59 }
60
61 public function getDbType() {
63 }
64}
65
66$maintClass = CleanupArchiveUserText::class;
67require_once RUN_MAINTENANCE_IF_MAIN;
wfWaitForSlaves( $ifWritesSince=null, $wiki=false, $cluster=false, $timeout=null)
Waits for the replica DBs to catch up to the master position.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
const RUN_MAINTENANCE_IF_MAIN
getDbType()
Does the script need different DB access? By default, we give Maintenance scripts normal rights to th...
__construct()
Default constructor.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
requireExtension( $name)
Indicate that the specified extension must be loaded before the script can run.
output( $out, $channel=null)
Throw some output to the user.
addDescription( $text)
Set the description text.
static actorMigrationWriteOld()
Indicate whether we should still write old user fields.
const DB_MASTER
Definition defines.php:26