[buddypress-trac] [BuddyPress Trac] #7614: Group member count routine is bad
buddypress-trac
noreply at wordpress.org
Mon Oct 23 15:20:00 UTC 2017
#7614: Group member count routine is bad
-------------------------+-------------------------------------------------
Reporter: | Owner:
boonebgorges | Status: new
Type: enhancement | Milestone: Future Release
Priority: normal | Version:
Component: Groups | Keywords: needs-patch needs-unit-tests good-
Severity: normal | first-bug
-------------------------+-------------------------------------------------
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.
2. 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.
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/7614>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
More information about the buddypress-trac
mailing list