Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/204855

Change subject: Add script to fix bad SULF renames on be_x_oldwiki
......................................................................

Add script to fix bad SULF renames on be_x_oldwiki

Change-Id: I64c95b826d27a6af4816b5fffc28882e0395d6d7
---
A fixBeXOldRenames.php
1 file changed, 71 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikimediaMaintenance 
refs/changes/55/204855/1

diff --git a/fixBeXOldRenames.php b/fixBeXOldRenames.php
new file mode 100644
index 0000000..86a2f2e
--- /dev/null
+++ b/fixBeXOldRenames.php
@@ -0,0 +1,71 @@
+<?php
+
+$IP = getenv( 'MW_INSTALL_PATH' );
+if ( $IP === false ) {
+       $IP = __DIR__ . '/../../..';
+}
+require_once "$IP/maintenance/Maintenance.php";
+
+/**
+ * During SUL finalization, users on be_x_old wiki were renamed to
+ * User:Foo~be_x_oldwiki, which is an invalid username. This script
+ * takes a list of those bad usernames, and renames them to
+ * User:Foo~be-x-oldwiki
+ */
+class FixBeXOldRenames extends Maintenance {
+       public function execute() {
+               $list = $this->getOption( 'list' );
+               $file = fopen( $list, 'r' );
+               if ( $file === false ) {
+                       $this->output( "ERROR - Could not open file: $list" );
+                       exit( 1 );
+               } else {
+                       $this->output( "Reading from $list\n" );
+               }
+               $count = 0;
+               while ( $line = trim( fgets( $file ) ) ) {
+                       $this->output( "$line\n" );
+                       $this->rename( $line );
+                       $count++;
+                       if ( $count > 30 ) {
+                               $this->output( "Waiting for slaves..." );
+                               CentralAuthUser::waitForSlaves();
+                               wfWaitForSlaves();
+                               $this->output( "done.\n" );
+                       }
+               }
+               fclose( $file );
+
+       }
+
+       protected function rename( $oldname ) {
+               $oldUser = User::newFromName( $oldname, false );
+               $newUser = User::newFromName( str_replace( '_', '-', $oldname 
), 'usable' );
+               $maintScript = User::newFromName( 'Maintenance script' );
+               $session = array(
+                       'userId' => $maintScript->getId(),
+                       'ip' => '127.0.01',
+                       'sessionId' => '0',
+                       'headers' => array(),
+               );
+               $data = array(
+                       'movepages' => true,
+                       'suppressredirects' => true,
+                       'reason' => '[[m:Special:MyLanguage/Single User Login 
finalisation announcement|SUL finalization]]',
+                       'force' => true,
+               );
+               $globalRenameUser = new GlobalRenameUser(
+                       $maintScript,
+                       $oldUser,
+                       CentralAuthUser::getInstance( $oldUser ),
+                       $newUser,
+                       CentralAuthUser::getInstance( $newUser ),
+                       new GlobalRenameUserStatus( $newUser->getName() ),
+                       'JobQueueGroup::singleton',
+                       new GlobalRenameUserDatabaseUpdates(),
+                       new GlobalRenameUserLogger( $maintScript ),
+                       $session
+               );
+               $globalRenameUser->rename( $data );
+       }
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/204855
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I64c95b826d27a6af4816b5fffc28882e0395d6d7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikimediaMaintenance
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to