Type: Regression Bug
Affects Version/s: 7.0.0 Alpha 5
When a user group is deleted, the user-userGroup mapping for the creator (owner) of the user group is lost.
1. Log in with test user
2. Create 2 another admin users: user1, user2 (currently I cannot add test admin to any user groups)
3. Log in with user1
4. Create 2 user groups, usergroup1, usergroup2
5. Add user1 and user2 users to usergroup1.
6. Delete usergroup2
7. Check usergroup1's memberships
Result: user1 is dropped out.
Expected Result: user1 is still a member of usergroup1
1. UserGroupLocalService.clearUserUserGroups(long userId) was originally created for
LEP-3236. When importing from LDAP the way to update users and user groups associations was to delete all of these then reimport.
LEP-5327 Handled user group deletion. This tried to use clearUserUserGroups() in the case when inactive users were associated with the user group. After the confirmation these associations were deleted.
Here at commit: 1dcafcf080e41f659ba3d3bd746a641966176c95 clearUserUserGroups(userGroupId); was added which called this method with userGroupId instead of userId.
(I think that the intention here was to check if active users are associated with the group, then if not, then clean up the inactive users.)
At this time: only the _importGroupsAndMembershipFromLDAPUser was calling this method.
So probably nothing ever happened because there was no user with the groupId until...
This modification revealed the bug.
This part should be removed because when you delete a user group, then UserGroupPersistenceImpl handles and deletes the association between the user group (to be deleted) and all (possible inactive) users attached to it.
Note: You cannot delete a user group if there are active users associated with it.