Ticket #40201: 40201.2.diff
File 40201.2.diff, 2.4 KB (added by , 7 years ago) |
---|
-
src/wp-includes/ms-blogs.php
258 258 * Clear the blog details cache. 259 259 * 260 260 * @since MU (3.0.0) 261 * @deprecated 4.9.0 Use clean_blog_cache() 262 * @see clean_blog_cache() 261 263 * 262 264 * @param int $blog_id Optional. Blog ID. Defaults to current blog. 263 265 */ 264 266 function refresh_blog_details( $blog_id = 0 ) { 267 _deprecated_function( __FUNCTION__, '4.9.0', 'clean_blog_cache()' ); 268 265 269 $blog_id = (int) $blog_id; 266 270 if ( ! $blog_id ) { 267 271 $blog_id = get_current_blog_id(); 268 272 } 269 273 270 $details = get_site( $blog_id ); 271 if ( ! $details ) { 272 // Make sure clean_blog_cache() gets the blog ID 273 // when the blog has been previously cached as 274 // non-existent. 275 $details = (object) array( 276 'blog_id' => $blog_id, 277 'domain' => null, 278 'path' => null 279 ); 280 } 281 282 clean_blog_cache( $details ); 283 284 /** 285 * Fires after the blog details cache is cleared. 286 * 287 * @since 3.4.0 288 * 289 * @param int $blog_id Blog ID. 290 */ 291 do_action( 'refresh_blog_details', $blog_id ); 274 clean_blog_cache( $blog_id ); 292 275 } 293 276 294 277 /** … … 445 428 * 446 429 * @global bool $_wp_suspend_cache_invalidation 447 430 * 448 * @param WP_Site $blog The site objectto be cleared from cache.431 * @param WP_Site|int $blog The site object or ID to be cleared from cache. 449 432 */ 450 function clean_blog_cache( $blog ) {433 function clean_blog_cache( $blog = 0 ) { 451 434 global $_wp_suspend_cache_invalidation; 452 435 453 436 if ( ! empty( $_wp_suspend_cache_invalidation ) ) { 454 437 return; 455 438 } 456 439 440 441 $blog_id = $blog; 442 $blog = get_site( $blog_id ); 443 if ( ! $blog && is_numeric( $blog_id ) ) { 444 // Make sure a WP_Site object exists even when the site has been deleted. 445 $blog = new WP_Site( (object) array( 446 'blog_id' => $blog_id, 447 'domain' => null, 448 'path' => null, 449 ) ); 450 } 451 452 457 453 $blog_id = $blog->blog_id; 458 454 $domain_path_key = md5( $blog->domain . $blog->path ); 459 455 … … 478 474 do_action( 'clean_site_cache', $blog_id, $blog, $domain_path_key ); 479 475 480 476 wp_cache_set( 'last_changed', microtime(), 'sites' ); 477 478 /** 479 * Fires after the blog details cache is cleared. 480 * 481 * @since 3.4.0 482 * @deprecated 4.9.0 Use clean_site_cache 483 * 484 * @param int $blog_id Blog ID. 485 */ 486 do_action_deprecated( 'refresh_blog_details', array( $blog_id ), '4.9.0', 'clean_site_cache' ); 481 487 } 482 488 483 489 /**