Opened 7 years ago
Closed 7 years ago
#7595 closed defect (bug) (fixed)
Use WP_User::get_data_by in BP_Core_User::get_core_userdata (remove custom user object cache)
Reported by: | johnjamesjacoby | Owned by: | johnjamesjacoby |
---|---|---|---|
Milestone: | 3.0 | Priority: | normal |
Severity: | normal | Version: | 1.2 |
Component: | Members | Keywords: | has-patch commit |
Cc: |
Description
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 WordPress.
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.
Attachments (1)
Change History (6)
#2
@
7 years ago
The only caveat is that we'd need to remove the "user not found" caching that was added in r11611.
I'm fine with this. Currently, with the exception of private message content, deleted users do not have their data kept in the DB.
Let's go with JJJ's patch for now.
#3
@
7 years ago
- Keywords commit added
- Milestone changed from Awaiting Review to 3.0
Looks great. Can you commit, @johnjamesjacoby?
It's worth noting that the Options API does this with a
notoptions
cache. It's weird and unique, but it solves this exact problem in a way that probably shouldn't be as unique as it is.