Opened 13 years ago
Closed 8 years ago
#3807 closed enhancement (fixed)
groups_get_group() and BP_Groups_Group tuning
Reported by: | boonebgorges | Owned by: | |
---|---|---|---|
Milestone: | 2.7 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Groups | Keywords: | |
Cc: | georgemamadashvili@… |
Description
Currently, when you load a group object, you also get things like group admins and mods, which adds a query. When all you need is, for example, the group name or the group avatar, you don't need this info. There should be a way to call up the group without getting this extra crap.
Change History (5)
#3
@
8 years ago
- Keywords needs-patch added
Yes, a parameter to exclude just these options would be a start.
A more complete solution, IMO, would be to do the following:
- Ensure that the admin/mods query is properly cached.
- Lazy-load the admin/mods data. That is: make the properties protected, limiting access to
__get()
; and in__get()
, fetch them only if they're needed. In the case of a groups loop, I'd say that they should all be pre-fetched into the cache no matter what (unless we want some sort of more sophisticated lazyload like WP does: https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-wp-metadata-lazyloader.php). But the more simple lazy-load would be quite effective when callinggroups_get_group()
outside of a loop.
This ticket was mentioned in Slack in #buddypress by dcavins. View the logs.
8 years ago
Note: See
TracTickets for help on using
tickets.
The Admin/Mods query is all part of the "generic" populate_extras argument, which is your basic true/false boolean value.
We would need to separate out and/or add extra params to
$group_args
to indicate whether or not to fetch these values, and act accordingly inside of BP_Groups_Group class.Perhaps add both a param and/or a filter to exclude, and leave included by default to avoid backcompat issues.