From 9edd8df844afeb94c96792c089198afd5d87011a Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Sun, 26 Jun 2016 14:29:28 +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. Built from https://develop.svn.wordpress.org/trunk@37874 git-svn-id: http://core.svn.wordpress.org/trunk@37815 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/ms-blogs.php | 10 +++++++++- wp-includes/version.php | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/wp-includes/ms-blogs.php b/wp-includes/ms-blogs.php index f0dcb9477d..90e43d2b6f 100644 --- a/wp-includes/ms-blogs.php +++ b/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. diff --git a/wp-includes/version.php b/wp-includes/version.php index 328d9e95c1..5f9d0fb479 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.6-alpha-37873'; +$wp_version = '4.6-alpha-37874'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.