Improvements to refreshing of total_group_count on group membership events
When group membership status is changed for a user, that user's
total_group_count meta must be updated. This changeset introduces a number of
improvements to the way this updating is done:
- Update using an actual queried group count, rather than incrementing. This
ensures that even if the count is off (due to a bug in BP or some other
plugin), it will be corrected the next time a membership event is recorded.
- Move the total_group_count refreshing further down the stack. Previously, the
updating was happening at various depths: sometimes in the
bp-groups-functions.php functions, sometimes in the database methods, and
sometimes not at all. By moving the updates so that they directly follow the
database queries, we reduce redundancy and ensure that the group count is
updated in all cases
This changeset also introduces integration tests for the relevant groups_*
membership functions and total_group_count.
Fixes #5018
Props mukkundthanki, r-a-y for early patches