X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FmigrateUserGroup.php;h=396be1d7ea4cdc8a421f2a3f49ce2d9132daaefc;hb=acb085d21af97f0e6019845e3ce672ec478c79ac;hp=a0c41fdc086de899c01d40bbeb3c6bd9c2e6a6e6;hpb=ba3cac4023165efeeee8a0e5075596410d2d8fe3;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/migrateUserGroup.php b/maintenance/migrateUserGroup.php index a0c41fdc08..396be1d7ea 100644 --- a/maintenance/migrateUserGroup.php +++ b/maintenance/migrateUserGroup.php @@ -31,7 +31,7 @@ require_once __DIR__ . '/Maintenance.php'; 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 ); @@ -41,11 +41,11 @@ class MigrateUserGroup extends Maintenance { $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__ ); + [ 'ug_group' => $oldGroup ], __FUNCTION__ ); $end = $dbw->selectField( 'user_groups', 'MAX(ug_user)', - array( 'ug_group' => $oldGroup ), __FUNCTION__ ); + [ 'ug_group' => $oldGroup ], __FUNCTION__ ); if ( $start === null ) { $this->error( "Nothing to do - no users in the '$oldGroup' group", true ); } @@ -60,11 +60,11 @@ class MigrateUserGroup extends Maintenance { $this->beginTransaction( $dbw, __METHOD__ ); $dbw->update( 'user_groups', - array( 'ug_group' => $newGroup ), - array( 'ug_group' => $oldGroup, - "ug_user BETWEEN $blockStart AND $blockEnd" ), + [ 'ug_group' => $newGroup ], + [ 'ug_group' => $oldGroup, + "ug_user BETWEEN $blockStart AND $blockEnd" ], __METHOD__, - array( 'IGNORE' ) + [ 'IGNORE' ] ); $affected += $dbw->affectedRows(); // Delete rows that the UPDATE operation above had to ignore. @@ -72,8 +72,8 @@ class MigrateUserGroup extends Maintenance { // Updating the row for the old group membership failed since // user/group is UNIQUE. $dbw->delete( 'user_groups', - array( 'ug_group' => $oldGroup, - "ug_user BETWEEN $blockStart AND $blockEnd" ), + [ 'ug_group' => $oldGroup, + "ug_user BETWEEN $blockStart AND $blockEnd" ], __METHOD__ ); $affected += $dbw->affectedRows(); @@ -84,8 +84,8 @@ class MigrateUserGroup extends Maintenance { // XXX: This also invalidates cache of unaffected users that // were in the new group and not in the group. $res = $dbw->select( 'user_groups', 'ug_user', - array( 'ug_group' => $newGroup, - "ug_user BETWEEN $blockStart AND $blockEnd" ), + [ 'ug_group' => $newGroup, + "ug_user BETWEEN $blockStart AND $blockEnd" ], __METHOD__ ); if ( $res !== false ) {