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
This commit is contained in:
Jeremy Felt 2017-03-28 19:36:49 +00:00
parent 6530f5f5f2
commit 0e7e0aa4bc
2 changed files with 20 additions and 4 deletions

View File

@ -443,20 +443,28 @@ function update_blog_details( $blog_id, $details = array() ) {
* *
* @since 3.5.0 * @since 3.5.0
* *
* @global bool $_wp_suspend_cache_invalidation
*
* @param WP_Site $blog The site object to be cleared from cache. * @param WP_Site $blog The site object to be cleared from cache.
*/ */
function clean_blog_cache( $blog ) { function clean_blog_cache( $blog ) {
global $_wp_suspend_cache_invalidation;
if ( ! empty( $_wp_suspend_cache_invalidation ) ) {
return;
}
$blog_id = $blog->blog_id; $blog_id = $blog->blog_id;
$domain_path_key = md5( $blog->domain . $blog->path ); $domain_path_key = md5( $blog->domain . $blog->path );
wp_cache_delete( $blog_id, 'sites' ); wp_cache_delete( $blog_id, 'sites' );
wp_cache_delete( $blog_id, 'site-details' ); 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( $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, 'site-options' );
wp_cache_delete( 'current_blog_' . $blog->domain . $blog->path, '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. * 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 * @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. * @param int|array $ids Network ID or an array of network IDs to remove from cache.
*/ */
function clean_network_cache( $ids ) { function clean_network_cache( $ids ) {
global $_wp_suspend_cache_invalidation;
if ( ! empty( $_wp_suspend_cache_invalidation ) ) {
return;
}
foreach ( (array) $ids as $id ) { foreach ( (array) $ids as $id ) {
wp_cache_delete( $id, 'networks' ); wp_cache_delete( $id, 'networks' );

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @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. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.