MediaWiki  1.33.0
cleanupArchiveUserText.php
Go to the documentation of this file.
1 <?php
2 
3 $IP = getenv( 'MW_INSTALL_PATH' );
4 if ( $IP === false ) {
5  $IP = __DIR__ . '/../../..';
6 }
7 
8 require_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() {
62  return Maintenance::DB_ADMIN;
63  }
64 }
65 
67 require_once RUN_MAINTENANCE_IF_MAIN;
$IP
$IP
Definition: cleanupArchiveUserText.php:3
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition: Maintenance.php:329
CleanupArchiveUserText\__construct
__construct()
Default constructor.
Definition: cleanupArchiveUserText.php:14
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
$res
$res
Definition: database.txt:21
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
wfWaitForSlaves
wfWaitForSlaves( $ifWritesSince=null, $wiki=false, $cluster=false, $timeout=null)
Waits for the replica DBs to catch up to the master position.
Definition: GlobalFunctions.php:2790
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
RenameuserSQL\actorMigrationWriteOld
static actorMigrationWriteOld()
Indicate whether we should still write old user fields.
Definition: RenameuserSQL.php:404
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2636
CleanupArchiveUserText\getDbType
getDbType()
Does the script need different DB access? By default, we give Maintenance scripts normal rights to th...
Definition: cleanupArchiveUserText.php:61
Maintenance\requireExtension
requireExtension( $name)
Indicate that the specified extension must be loaded before the script can run.
Definition: Maintenance.php:619
DB_MASTER
const DB_MASTER
Definition: defines.php:26
Maintenance\DB_ADMIN
const DB_ADMIN
Definition: Maintenance.php:79
CleanupArchiveUserText
Definition: cleanupArchiveUserText.php:13
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:434
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
$maintClass
$maintClass
Definition: cleanupArchiveUserText.php:66
CleanupArchiveUserText\execute
execute()
Do the actual work.
Definition: cleanupArchiveUserText.php:22