From 0e7e0aa4bc19c39ce9cc64ce860033a953ad80c3 Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Tue, 28 Mar 2017 19:36:49 +0000 Subject: [PATCH] Multisite: Respect `$_wp_suspend_cache_invalidation` when clearing network and site caches. Props johnjamesjacoby. Fixes #40028. Built from https://develop.svn.wordpress.org/trunk@40346 git-svn-id: http://core.svn.wordpress.org/trunk@40253 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/ms-blogs.php | 22 +++++++++++++++++++--- wp-includes/version.php | 2 +- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/wp-includes/ms-blogs.php b/wp-includes/ms-blogs.php index 4f0e26085a..50e3358bcc 100644 --- a/wp-includes/ms-blogs.php +++ b/wp-includes/ms-blogs.php @@ -443,20 +443,28 @@ function update_blog_details( $blog_id, $details = array() ) { * * @since 3.5.0 * + * @global bool $_wp_suspend_cache_invalidation + * * @param WP_Site $blog The site object to be cleared from cache. */ function clean_blog_cache( $blog ) { + global $_wp_suspend_cache_invalidation; + + if ( ! empty( $_wp_suspend_cache_invalidation ) ) { + return; + } + $blog_id = $blog->blog_id; $domain_path_key = md5( $blog->domain . $blog->path ); wp_cache_delete( $blog_id, 'sites' ); wp_cache_delete( $blog_id, 'site-details' ); - wp_cache_delete( $blog_id , 'blog-details' ); + wp_cache_delete( $blog_id, 'blog-details' ); wp_cache_delete( $blog_id . 'short' , 'blog-details' ); - wp_cache_delete( $domain_path_key, 'blog-lookup' ); + wp_cache_delete( $domain_path_key, 'blog-lookup' ); + wp_cache_delete( $domain_path_key, 'blog-id-cache' ); wp_cache_delete( 'current_blog_' . $blog->domain, 'site-options' ); wp_cache_delete( 'current_blog_' . $blog->domain . $blog->path, 'site-options' ); - wp_cache_delete( $domain_path_key, 'blog-id-cache' ); /** * Fires immediately after a site has been removed from the object cache. @@ -1149,9 +1157,17 @@ function get_network( $network = null ) { * * @since 4.6.0 * + * @global bool $_wp_suspend_cache_invalidation + * * @param int|array $ids Network ID or an array of network IDs to remove from cache. */ function clean_network_cache( $ids ) { + global $_wp_suspend_cache_invalidation; + + if ( ! empty( $_wp_suspend_cache_invalidation ) ) { + return; + } + foreach ( (array) $ids as $id ) { wp_cache_delete( $id, 'networks' ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 7a8440d0a4..6ba32bc783 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.8-alpha-40344'; +$wp_version = '4.8-alpha-40346'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.