From 846510ea6f132d54966350fe4eb198eadb1382ef Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Wed, 7 Oct 2015 22:42:25 +0000 Subject: [PATCH] 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 --- wp-includes/user-functions.php | 13 +++++++++++-- wp-includes/version.php | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/wp-includes/user-functions.php b/wp-includes/user-functions.php index fd73875958..9e95bee6c7 100644 --- a/wp-includes/user-functions.php +++ b/wp-includes/user-functions.php @@ -1102,9 +1102,18 @@ function sanitize_user_field($field, $value, $user_id, $context) { * * @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->user_login, $user->ID, 'userlogins'); wp_cache_add($user->user_email, $user->ID, 'useremail'); diff --git a/wp-includes/version.php b/wp-includes/version.php index 6e5d5d9c01..bebc61f0b0 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @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.