From 90b85743a72669b1b5b58fb90461aa10da7286ce Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Sun, 26 Jun 2016 14:28:35 +0000 Subject: [PATCH] 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 --- src/wp-includes/ms-blogs.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/ms-blogs.php b/src/wp-includes/ms-blogs.php index f0dcb9477d..90e43d2b6f 100644 --- a/src/wp-includes/ms-blogs.php +++ b/src/wp-includes/ms-blogs.php @@ -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.