Opened 10 years ago
Closed 10 years ago
#5711 closed enhancement (fixed)
BP_Groups_Member::get_group_administrator_ids() not cached
Reported by: | r-a-y | Owned by: | r-a-y |
---|---|---|---|
Milestone: | 2.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Groups | Keywords: | has-patch commit |
Cc: |
Description
In the group loop, when the "Leave Group" button is in the process of rendering, groups_get_group_admins()
is called.
groups_get_group_admins()
therein calls BP_Groups_Member::get_group_administrator_ids()
. This DB query is uncached.
If the logged-in user is viewing the group directory and is a member of each group in the loop, this can lead to 20 additional DB queries being run.
Attached patch caches calls to BP_Groups_Member::get_group_administrator_ids()
and invalidates the cache whenever a group member is promoted or demoted and when a group is deleted. Let me know if more unit tests are required.
Nice catch. Caching looks good to me.
I know we don't allow it anywhere in the interface (admin status only comes through promotion), but it's possible to create group admins programatically without going through the promotion process. I think it's probably worth busting the cache on changes in group membership for this reason. (Adds very little overhead, since this happens rarely.) What do you think?