Handle `WP_User` objects properly in `update_user_caches()`.

We should not be storing the `WP_User` object in the cache, as it may contain
usermeta and other data that's cache elsewhere.

Props dd32.
See #24635.
Built from https://develop.svn.wordpress.org/trunk@34919


git-svn-id: http://core.svn.wordpress.org/trunk@34884 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2015-10-07 22:42:25 +00:00
parent b0e0323337
commit 846510ea6f
2 changed files with 12 additions and 3 deletions

View File

@ -1102,9 +1102,18 @@ function sanitize_user_field($field, $value, $user_id, $context) {
* *
* @since 3.0.0 * @since 3.0.0
* *
* @param object $user User object to be cached * @param object|WP_User $user User object to be cached
* @return bool|null Returns false on failure.
*/ */
function update_user_caches($user) { function update_user_caches( $user ) {
if ( $user instanceof WP_User ) {
if ( ! $user->exists() ) {
return false;
}
$user = $user->data;
}
wp_cache_add($user->ID, $user, 'users'); wp_cache_add($user->ID, $user, 'users');
wp_cache_add($user->user_login, $user->ID, 'userlogins'); wp_cache_add($user->user_login, $user->ID, 'userlogins');
wp_cache_add($user->user_email, $user->ID, 'useremail'); wp_cache_add($user->user_email, $user->ID, 'useremail');

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.4-alpha-34918'; $wp_version = '4.4-alpha-34919';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.