Skip to:
Content

BuddyPress.org

Opened 2 years ago

#7614 new enhancement

Group member count routine is bad

Reported by: boonebgorges Owned by:
Milestone: Awaiting Contributions Priority: normal
Severity: normal Version:
Component: Groups Keywords: needs-patch needs-unit-tests good-first-bug
Cc:

Description

There are in fact two bad things going on here, but they're closely related, so I'm lumping them together.

  1. Group member count is stored in groupmeta for performance. This count is refreshed every time a group's Members page is viewed. https://buddypress.trac.wordpress.org/browser/tags/2.9.1/src/bp-groups/bp-groups-screens.php?marks=585#L573 [2858] This is bad. This cached value only needs updating when a member joins or leaves.
  1. The method used to query the group member count is groups_get_total_member_count(), which calls BP_Groups_Group::get_total_member_count(), which makes a direct SQL query. This query doesn't take into account whether users are activated in WP (see user_status or spam in the wp_users table, it ignores whether the users in question even exist in wp_users, it is not filterable, and it is not cached. We should not use it. This should be switched to a regular group member query, with 'count' functionality added to that query class if it's not already there.

Change History (0)

Note: See TracTickets for help on using tickets.