[wp-trac] [WordPress Trac] #36508: Call cache_users() when 'fields'=>'all' in WP_User_Query
WordPress Trac
noreply at wordpress.org
Wed Apr 13 16:07:55 UTC 2016
#36508: Call cache_users() when 'fields'=>'all' in WP_User_Query
-------------------------------------+--------------------------
Reporter: danielbachhuber | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 4.6
Component: Users | Version:
Severity: normal | Resolution:
Keywords: has-patch needs-testing | Focuses: performance
-------------------------------------+--------------------------
Changes (by boonebgorges):
* keywords: needs-patch => has-patch needs-testing
* milestone: Future Release => 4.6
Comment:
This is more complicated than I'd originally thought. (Gee, I end up
saying that a lot.) You can't prime WP's metadata cache for a single key.
Cached data is keyed by object ID (such as `user_id`), and if
`get_metadata()` finds that `$cache[ $user_id ]` is populated, it assumes
that it's *completely* populated (ie, with all of `$user_id`'s usermeta).
Invalidation, cache priming, and a bunch of other stuff is tied up with
this schema.
Instead, I opted in [attachment:36508.diff] to run a very specific query
within `WP_User_Query`, and then pass an array of `$raw_caps` to the
`WP_User` object, which `WP_User` uses instead of `get_user_meta( $cap_key
)`. The structure of `WP_User` makes it impossible to do this in a non-
clunky way, but the patch works.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36508#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list