Multisite: Clear incomplete objects from cache in `get_blog_details()` when found.

In [37657], the `blog_id` and `site_id` properties were changed to private. Any `WP_Site` objects previously stored in cache with public properties should now be considered invalid. We can detect this by checking for these missing properties and clearing the dirty cache if found.

Props flixos90.
Fixes #36717.


git-svn-id: https://develop.svn.wordpress.org/trunk@37874 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jeremy Felt 2016-06-26 14:28:35 +00:00
parent b28ca0f4b8
commit 90b85743a7
1 changed files with 9 additions and 1 deletions

View File

@ -183,6 +183,10 @@ function get_blog_details( $fields = null, $get_all = true ) {
wp_cache_delete( $blog_id . $all, 'blog-details' );
unset($details);
}
} elseif ( ! $details->blog_id || ! $details->site_id ) {
// Clear objects missing critical properties.
wp_cache_delete( $blog_id . $all, 'blog-details' );
unset($details);
} else {
return $details;
}
@ -203,13 +207,17 @@ function get_blog_details( $fields = null, $get_all = true ) {
wp_cache_delete( $blog_id, 'blog-details' );
unset($details);
}
} elseif ( ! $details->blog_id || ! $details->site_id ) {
// Clear objects missing critical properties.
wp_cache_delete( $blog_id, 'blog-details' );
unset($details);
} else {
return $details;
}
}
}
if ( empty($details) ) {
if ( empty( $details ) || ! $details->blog_id || ! $details->site_id ) {
$details = WP_Site::get_instance( $blog_id );
if ( ! $details ) {
// Set the full cache.