Make WordPress Core

Changeset 16225


Ignore:
Timestamp:
11/06/2010 06:45:20 PM (14 years ago)
Author:
ryan
Message:

Prime blogs of user cache from old cache to avoid mass DB requests on upgrade. see #14379

File:
1 edited

Legend:

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

    r16181 r16225  
    617617
    618618    $blogs = wp_cache_get( 'blogs_of_user-' . $id, 'users' );
     619
     620    // Try priming the new cache from the old cache
     621    if ( false === $blogs ) {
     622        $cache_suffix = $all ? '_all' : '_short';
     623        $blogs = wp_cache_get( 'blogs_of_user_' . $id . $cache_suffix, 'users' );
     624        if ( is_array( $blogs ) ) {
     625            $blogs = array_keys( $blogs );
     626            if ( $all )
     627                wp_cache_set( 'blogs_of_user-' . $id, $blogs, 'users' );
     628        }
     629    }
     630
    619631    if ( false === $blogs ) {
    620632        $user = get_userdata( (int) $id );
Note: See TracChangeset for help on using the changeset viewer.