29require_once __DIR__ .
'/Maintenance.php';
34 parent::__construct();
35 $this->
addDescription(
'Remove all users from a given user group' );
36 $this->
addArg(
'group',
'Group to be removed',
true );
41 $group = $this->
getArg( 0 );
45 $this->
output(
"Removing users from $group...\n" );
47 $users = User::findUsersByGroup( $group, $this->
getBatchSize() );
48 if ( iterator_count( $users ) === 0 ) {
52 foreach ( $users as $user ) {
53 $totalCount += (int)$userGroupManager->removeUserFromGroup( $user, $group );
58 $this->
output(
" ...done! Removed $totalCount users in total.\n" );
60 $this->
output(
" ...nothing to do, group was empty.\n" );
67require_once RUN_MAINTENANCE_IF_MAIN;
execute()
Do the actual work.
__construct()
Default constructor.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
addArg( $arg, $description, $required=true, $multi=false)
Add some args that are needed.
getArg( $argId=0, $default=null)
Get an argument.
getBatchSize()
Returns batch size.
output( $out, $channel=null)
Throw some output to the user.
waitForReplication()
Wait for replica DB servers to catch up.
getServiceContainer()
Returns the main service container.
addDescription( $text)
Set the description text.