class MigrateUserGroup extends Maintenance {
public function __construct() {
parent::__construct();
- $this->mDescription = "Re-assign users from an old group to a new one";
+ $this->addDescription( '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 );
$count = 0;
$oldGroup = $this->getArg( 0 );
$newGroup = $this->getArg( 1 );
- $dbw = wfGetDB( DB_MASTER );
+ $dbw = $this->getDB( DB_MASTER );
$start = $dbw->selectField( 'user_groups', 'MIN(ug_user)',
array( 'ug_group' => $oldGroup ), __FUNCTION__ );
$end = $dbw->selectField( 'user_groups', 'MAX(ug_user)',
$affected = 0;
$this->output( "Doing users $blockStart to $blockEnd\n" );
- $dbw->begin( __METHOD__ );
+ $this->beginTransaction( $dbw, __METHOD__ );
$dbw->update( 'user_groups',
array( 'ug_group' => $newGroup ),
array( 'ug_group' => $oldGroup,
__METHOD__
);
$affected += $dbw->affectedRows();
- $dbw->commit( __METHOD__ );
+ $this->commitTransaction( $dbw, __METHOD__ );
// Clear cache for the affected users (bug 40340)
if ( $affected > 0 ) {