[wp-trac] [WordPress Trac] #24635: update_user_caches() should support accepting a WP_User instance
WordPress Trac
noreply at wordpress.org
Mon Jun 24 08:19:54 UTC 2013
#24635: update_user_caches() should support accepting a WP_User instance
--------------------------+-----------------------------
Reporter: dd32 | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Users | Version: trunk
Severity: normal | Keywords: has-patch
--------------------------+-----------------------------
At present update_user_caches($user) blindly stores the value from $user
into the object cache.
Although core only ever passes the raw data from `wp_users` into this
function, due to the naming of it, and the phpdoc, plugin devs may pass a
WP_User instance to the function.
The result is that a WP_User instance is stored within the object cache
rather than stdClass of a `wp_users` row as expected.
For most intents this causes little issue, the function and cache still
work, so the developer will see no side effects.
But this has the cause that when that user's data is retrieved from the
cache, the original WP_User object is restored -- including all meta keys
that were stored in it, If one of those meta keys is a serialized object
which calls a not-yet-loaded function, it can cause the request to fatal
error. It's a pretty specific issue, but can simply be avoided by never
storing a WP_User instance in the cache.
Attached patch simply tests for the data and acts appropriately. mostly
untested.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/24635>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list