[buddypress-trac] [BuddyPress Trac] #7595: Use WP_User::get_data_by in BP_Core_User::get_core_userdata (remove custom user object cache)

buddypress-trac noreply at wordpress.org
Wed Sep 13 19:41:45 UTC 2017

#7595: Use WP_User::get_data_by in BP_Core_User::get_core_userdata (remove custom
user object cache)
 Reporter:  johnjamesjacoby  |      Owner:
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Members          |    Version:  1.2
 Severity:  normal           |   Keywords:  has-patch 2nd-opinion
 The method & approach in BuddyPress now is a relic from before WordPress
 had a reliable way to just get a user object (without caps & meta.)

 `BP_Core_User::get_core_userdata()` currently calls a raw database query
 to `wp_users` to get a user from a `$user_id`, which bypasses cache
 entirely. Custom user object caching is done inside of
 `bp_core_get_core_userdata()`, instead of using what's already provided by

 By trusting `WP_User::get_data_by()` instead, BuddyPress becomes less
 complex by eliminating an entire cache layer, and its userdata is
 guaranteed to be inline with WordPress and any plugins that might be
 calling `wp_update_user()` on their own.

 Performance improvements on a bbPress installation are pretty impressive.
 Forum sections with fully populated and paginated forums & topics can see
 a 30+ query reduction, with an equivalent improvement for cache misses.

 The only caveat is that we'd need to remove the "user not found" caching
 that was added in r11611. FWIW, I think this is fine. I think if we want
 to handle the caching of missing users/objects, we should probably
 recommend a patch upstream to WordPress core to handle this more elegantly
 for all missing objects.

 Patch imminent.

Ticket URL: <https://buddypress.trac.wordpress.org/ticket/7595>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac

More information about the buddypress-trac mailing list