From 59bffc3071520edefd4df3ad35bc94fe7269384d Mon Sep 17 00:00:00 2001 From: ryan 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: http://svn.automattic.com/wordpress/trunk@16225 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/user.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/wp-includes/user.php b/wp-includes/user.php index d1d722892..6143990cd 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 )