This ticket is the result of the following comments:
1. https://gerrit.wikimedia.org/r/c/mediawiki/core/+/702607/5/maintenance/createAndPromote.php#154
2. https://gerrit.wikimedia.org/r/c/mediawiki/core/+/702607/8/includes/user/UserGroupManager.php#851
**Implementation**
UserGroupManager::addUserToGroup**s** method should help to avoid such situations --->
```
foreach ( $promotions as $promotion ) {
$userGroupManager->addUserToGroup( $user, $promotion );
}
```
or
[[ https://gerrit.wikimedia.org/g/mediawiki/core/+/871dc62208844dc7a249e83c5b7b429d04716f9b/includes/user/UserGroupManager.php#616 | an exapmle ]]
The new method must loop through the list of groups and call UserGroupManager::addUserToGroup every iteration.
**How must this ticket be accomplished?**
1. You need to create the patch for the core in which you add new UserGroupManager::addUserToGroups method, create some test cases for the new method, replace all uses of a loop and UserGroupManager::addUserToGroup with ::addUserToGroups .
2. Find all uses of the exapmles above in the other codebases, file a separate ticket for each codebase and create an appropriate patch.