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

git-svn-id: https://develop.svn.wordpress.org/trunk@16225 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2010-11-06 18:45:20 +00:00
parent 840e539c0e
commit 94839a3f17

View File

@ -616,6 +616,18 @@ function get_blogs_of_user( $id, $all = false ) {
}
$blogs = wp_cache_get( 'blogs_of_user-' . $id, 'users' );
// Try priming the new cache from the old cache
if ( false === $blogs ) {
$cache_suffix = $all ? '_all' : '_short';
$blogs = wp_cache_get( 'blogs_of_user_' . $id . $cache_suffix, 'users' );
if ( is_array( $blogs ) ) {
$blogs = array_keys( $blogs );
if ( $all )
wp_cache_set( 'blogs_of_user-' . $id, $blogs, 'users' );
}
}
if ( false === $blogs ) {
$user = get_userdata( (int) $id );
if ( !$user )