diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2013-08-12 09:28:15 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2013-08-12 09:28:15 +0200 |
commit | 08aa4418c30cfc18ccc69a0f0f9cb9e17be6c196 (patch) | |
tree | 577a29fb579188d16003a209ce2a2e9c5b0aa2bd /extensions/Renameuser/cleanupArchiveUserText.php | |
parent | cacc939b34e315b85e2d72997811eb6677996cc1 (diff) |
Update to MediaWiki 1.21.1
Diffstat (limited to 'extensions/Renameuser/cleanupArchiveUserText.php')
-rw-r--r-- | extensions/Renameuser/cleanupArchiveUserText.php | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/extensions/Renameuser/cleanupArchiveUserText.php b/extensions/Renameuser/cleanupArchiveUserText.php new file mode 100644 index 00000000..8599f3c2 --- /dev/null +++ b/extensions/Renameuser/cleanupArchiveUserText.php @@ -0,0 +1,59 @@ +<?php + +$IP = getenv( 'MW_INSTALL_PATH' ); +if ( $IP === false ) { + $IP = __DIR__ . '/../..'; +} + +require_once( "$IP/maintenance/Maintenance.php" ); + +/** + * @ingroup Maintenance + */ +class CleanupArchiveUserText extends Maintenance { + public function __construct() { + parent::__construct(); + $this->mDescription = "Update the archive table where users were previously renamed, but their archive contributions were not"; + } + + public function execute() { + $dbw = wfGetDB( DB_MASTER ); + do { + $res = $dbw->select( + array( 'archive', 'user' ), + array( 'DISTINCT ar_user_text', 'user_name', 'ar_user' ), + array( + 'ar_user_text <> user_name', + 'ar_user = user_id', + ), + __METHOD__, + array( 'LIMIT' => 50 ) + ); + $results = 0; + foreach( $res as $row ) { + $results++; + $this->output( "User:{$row->ar_user_text} => User:{$row->user_name} " ); + $dbw->update( + 'archive', + array( 'ar_user_text' => $row->user_name ), + array( + 'ar_user_text' => $row->ar_user_text, + 'ar_user' => $row->ar_user, + ), + __METHOD__, + array( 'LIMIT' => 50 ) + ); + $affected = $dbw->affectedRows(); + $this->output( "$affected rows\n" ); + wfWaitForSlaves(); + } + } while ( $results === 50 ); + } + + public function getDbType() { + return Maintenance::DB_ADMIN; + } +} + +$maintClass = "CleanupArchiveUserText"; +require_once( RUN_MAINTENANCE_IF_MAIN ); |