Ticket #40028: 40028.2.diff
File 40028.2.diff, 2.9 KB (added by , 8 years ago) |
---|
-
src/wp-includes/ms-blogs.php
446 446 * @param WP_Site $blog The site object to be cleared from cache. 447 447 */ 448 448 function clean_blog_cache( $blog ) { 449 global $_wp_suspend_cache_invalidation; 450 451 if ( ! empty( $_wp_suspend_cache_invalidation ) ) { 452 return; 453 } 454 449 455 $blog_id = $blog->blog_id; 450 456 $domain_path_key = md5( $blog->domain . $blog->path ); 451 457 452 458 wp_cache_delete( $blog_id, 'sites' ); 453 459 wp_cache_delete( $blog_id, 'site-details' ); 454 wp_cache_delete( $blog_id 460 wp_cache_delete( $blog_id, 'blog-details' ); 455 461 wp_cache_delete( $blog_id . 'short' , 'blog-details' ); 456 wp_cache_delete( $domain_path_key, 'blog-lookup' ); 462 wp_cache_delete( $domain_path_key, 'blog-lookup' ); 463 wp_cache_delete( $domain_path_key, 'blog-id-cache' ); 457 464 wp_cache_delete( 'current_blog_' . $blog->domain, 'site-options' ); 458 465 wp_cache_delete( 'current_blog_' . $blog->domain . $blog->path, 'site-options' ); 459 wp_cache_delete( $domain_path_key, 'blog-id-cache' );460 466 461 467 /** 462 468 * Fires immediately after a site has been removed from the object cache. … … 1152 1158 * @param int|array $ids Network ID or an array of network IDs to remove from cache. 1153 1159 */ 1154 1160 function clean_network_cache( $ids ) { 1161 global $_wp_suspend_cache_invalidation; 1162 1163 if ( ! empty( $_wp_suspend_cache_invalidation ) ) { 1164 return; 1165 } 1166 1155 1167 foreach ( (array) $ids as $id ) { 1156 1168 wp_cache_delete( $id, 'networks' ); 1157 1169 -
tests/phpunit/tests/multisite/site.php
122 122 $this->assertEquals( 2, (int) get_blog_count() ); 123 123 } 124 124 125 public function test_site_caches_should_invalidate_when_invalidation_is_not_suspended() { 126 $site_id = self::factory()->blog->create(); 127 128 $details = get_site( $site_id ); 129 130 $suspend = wp_suspend_cache_invalidation( false ); 131 update_blog_details( $site_id, array( 'path' => '/a-non-random-test-path/' ) ); 132 $new_details = get_site( $site_id ); 133 wp_suspend_cache_invalidation( $suspend ); 134 135 $this->assertNotEquals( $details->path, $new_details->path ); 136 } 137 138 public function test_invalidating_site_caches_should_fail_when_invalidation_is_suspended() { 139 $site_id = self::factory()->blog->create(); 140 141 $details = get_site( $site_id ); 142 143 $suspend = wp_suspend_cache_invalidation(); 144 update_blog_details( $site_id, array( 'path' => '/a-non-random-test-path/' ) ); 145 $new_details = get_site( $site_id ); 146 wp_suspend_cache_invalidation( $suspend ); 147 148 $this->assertEquals( $details->path, $new_details->path ); 149 } 150 125 151 /** 126 152 * When a site is flagged as 'deleted', its data should be cleared from cache. 127 153 */