MediaWiki REL1_31
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->mDescription = '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';
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.
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.
static getActorMigrationStage()
Fetch the core actor table schema migration stage.
$res
Definition database.txt:21
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
const MIGRATION_NEW
Definition Defines.php:305
require_once RUN_MAINTENANCE_IF_MAIN
const DB_MASTER
Definition defines.php:29