Cache fixes for get_blog_details()

git-svn-id: https://develop.svn.wordpress.org/trunk@14076 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2010-04-13 12:43:40 +00:00
parent 7d823cbc23
commit dadff5dda0
1 changed files with 15 additions and 9 deletions

View File

@ -125,13 +125,16 @@ function get_blog_details( $fields, $get_all = true ) {
if ( $details ) {
if ( ! is_object( $details ) ) {
if ( $details == -1 )
if ( $details == -1 ) {
return false;
else
} else {
// Clear old pre-serialized objects. Cache clients do better with that.
wp_cache_delete( $blog_id . $all, 'blog-details' );
unset($details);
}
} else {
return $details;
}
return $details;
}
// Try the other cache.
@ -142,18 +145,21 @@ function get_blog_details( $fields, $get_all = true ) {
// If short was requested and full cache is set, we can return.
if ( $details ) {
if ( ! is_object( $details ) ) {
if ( $details == -1 )
if ( $details == -1 ) {
return false;
else
} else {
// Clear old pre-serialized objects. Cache clients do better with that.
wp_cache_delete( $blog_id . $all, 'blog-details' );
wp_cache_delete( $blog_id, 'blog-details' );
unset($details);
}
} else {
return $details;
}
return $details;
}
}
if ( !$details ) {
$details = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE blog_id = %d", $blog_id ) );
if ( empty($details) ) {
$details = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE blog_id = %d /* get_blog_details */", $blog_id ) );
if ( ! $details ) {
// Set the full cache.
wp_cache_set( $blog_id, -1, 'blog-details' );