From 94839a3f17aae3d4e215b63f2e66c6ddf9df189d Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Sat, 6 Nov 2010 18:45:20 +0000 Subject: [PATCH] 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 --- wp-includes/user.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/wp-includes/user.php b/wp-includes/user.php index d1d7228926..6143990cd4 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -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 )