Changeset 48044
- Timestamp:
- 06/15/2020 12:29:13 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/ms-blogs.php
r47808 r48044 239 239 } 240 240 241 switch_to_blog( $blog_id ); 241 $switched_blog = false; 242 243 if ( get_current_blog_id() !== $blog_id ) { 244 switch_to_blog( $blog_id ); 245 $switched_blog = true; 246 } 247 242 248 $details->blogname = get_option( 'blogname' ); 243 249 $details->siteurl = get_option( 'siteurl' ); 244 250 $details->post_count = get_option( 'post_count' ); 245 251 $details->home = get_option( 'home' ); 246 restore_current_blog(); 252 253 if ( $switched_blog ) { 254 restore_current_blog(); 255 } 247 256 248 257 /** … … 517 526 */ 518 527 do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'switch' ); 528 519 529 $GLOBALS['switched'] = true; 530 520 531 return true; 521 532 } … … 535 546 $global_groups = false; 536 547 } 548 537 549 wp_cache_init(); 538 550 … … 543 555 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details', 'blog_meta' ) ); 544 556 } 557 545 558 wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) ); 546 559 } … … 549 562 /** This filter is documented in wp-includes/ms-blogs.php */ 550 563 do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'switch' ); 564 551 565 $GLOBALS['switched'] = true; 552 566 … … 582 596 /** This filter is documented in wp-includes/ms-blogs.php */ 583 597 do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'restore' ); 598 584 599 // If we still have items in the switched stack, consider ourselves still 'switched'. 585 600 $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); 601 586 602 return true; 587 603 } … … 610 626 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details', 'blog_meta' ) ); 611 627 } 628 612 629 wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) ); 613 630 } -
trunk/tests/phpunit/tests/multisite/getBlogDetails.php
r47012 r48044 141 141 $site = get_blog_details( array( 'path' => '/foo/' ) ); 142 142 $this->assertFalse( $site ); 143 } 144 145 /** 146 * @ticket 50391 147 */ 148 public function test_get_blog_details_does_not_switch_to_current_blog() { 149 $count = did_action( 'switch_blog' ); 150 151 get_blog_details(); 152 $this->assertSame( $count, did_action( 'switch_blog' ) ); 143 153 } 144 154
Note: See TracChangeset
for help on using the changeset viewer.