Make WordPress Core


Ignore:
Timestamp:
10/07/2015 10:41:07 PM (10 years ago)
Author:
boonebgorges
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/user-functions.php

    r34912 r34919  
    11031103 * @since 3.0.0
    11041104 *
    1105  * @param object $user User object to be cached
    1106  */
    1107 function update_user_caches($user) {
     1105 * @param object|WP_User $user User object to be cached
     1106 * @return bool|null Returns false on failure.
     1107 */
     1108function update_user_caches( $user ) {
     1109    if ( $user instanceof WP_User ) {
     1110        if ( ! $user->exists() ) {
     1111            return false;
     1112        }
     1113
     1114        $user = $user->data;
     1115    }
     1116
    11081117    wp_cache_add($user->ID, $user, 'users');
    11091118    wp_cache_add($user->user_login, $user->ID, 'userlogins');
Note: See TracChangeset for help on using the changeset viewer.