From: Alexandre Emsenhuber Date: Mon, 7 Sep 2009 13:18:54 +0000 (+0000) Subject: * svn:eol-style native X-Git-Tag: 1.31.0-rc.0~39883 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/recherche.php?a=commitdiff_plain;h=87e7919e625ade6cfcbb519e9b9862701de16ec3;p=lhc%2Fweb%2Fwiklou.git * svn:eol-style native * svn:mime-type image/svg+xml on extensions/LiquidThreads/icons/quote.svg --- diff --git a/maintenance/migrateUserGroup.php b/maintenance/migrateUserGroup.php index ed9cd0325e..6d584f7d33 100644 --- a/maintenance/migrateUserGroup.php +++ b/maintenance/migrateUserGroup.php @@ -1,70 +1,70 @@ -mDescription = "Re-assign users from an old group to a new one"; - $this->addArg( 'oldgroup', 'Old user group key', true ); - $this->addArg( 'newgroup', 'New user group key', true ); - $this->setBatchSize( 200 ); - } - - public function execute() { - $count = 0; - $oldGroup = $this->getArg( 0 ); - $newGroup = $this->getArg( 1 ); - $dbw = wfGetDB( DB_MASTER ); - $start = $dbw->selectField( 'user_groups', 'MIN(ug_user)', - array('ug_group' => $oldGroup), __FUNCTION__ ); - $end = $dbw->selectField( 'user_groups', 'MAX(ug_user)', - array('ug_group' => $oldGroup), __FUNCTION__ ); - if( $start === null ) { - $this->error( "Nothing to do - no users in the '$oldGroup' group", true ); - } - # Do remaining chunk - $end += $this->mBatchSize - 1; - $blockStart = $start; - $blockEnd = $start + $this->mBatchSize - 1; - // Migrate users over in batches... - while( $blockEnd <= $end ) { - $this->output( "Doing users $blockStart to $blockEnd\n" ); - $dbw->begin(); - $dbw->update( 'user_groups', - array('ug_group' => $newGroup), - array('ug_group' => $oldGroup, - "ug_user BETWEEN $blockStart AND $blockEnd" ) - ); - $count += $dbw->affectedRows(); - $dbw->commit(); - $blockStart += $this->mBatchSize; - $blockEnd += $this->mBatchSize; - wfWaitForSlaves( 5 ); - } - $this->output( "Done! $count user(s) in group '$oldGroup' are now in '$newGroup' instead.\n" ); - } -} - -$maintClass = "MigrateUserGroup"; -require_once( DO_MAINTENANCE ); +mDescription = "Re-assign users from an old group to a new one"; + $this->addArg( 'oldgroup', 'Old user group key', true ); + $this->addArg( 'newgroup', 'New user group key', true ); + $this->setBatchSize( 200 ); + } + + public function execute() { + $count = 0; + $oldGroup = $this->getArg( 0 ); + $newGroup = $this->getArg( 1 ); + $dbw = wfGetDB( DB_MASTER ); + $start = $dbw->selectField( 'user_groups', 'MIN(ug_user)', + array('ug_group' => $oldGroup), __FUNCTION__ ); + $end = $dbw->selectField( 'user_groups', 'MAX(ug_user)', + array('ug_group' => $oldGroup), __FUNCTION__ ); + if( $start === null ) { + $this->error( "Nothing to do - no users in the '$oldGroup' group", true ); + } + # Do remaining chunk + $end += $this->mBatchSize - 1; + $blockStart = $start; + $blockEnd = $start + $this->mBatchSize - 1; + // Migrate users over in batches... + while( $blockEnd <= $end ) { + $this->output( "Doing users $blockStart to $blockEnd\n" ); + $dbw->begin(); + $dbw->update( 'user_groups', + array('ug_group' => $newGroup), + array('ug_group' => $oldGroup, + "ug_user BETWEEN $blockStart AND $blockEnd" ) + ); + $count += $dbw->affectedRows(); + $dbw->commit(); + $blockStart += $this->mBatchSize; + $blockEnd += $this->mBatchSize; + wfWaitForSlaves( 5 ); + } + $this->output( "Done! $count user(s) in group '$oldGroup' are now in '$newGroup' instead.\n" ); + } +} + +$maintClass = "MigrateUserGroup"; +require_once( DO_MAINTENANCE );