[wp-trac] [WordPress Trac] #21459: Cleanup switch_to_blog() and restore_current_blog()

WordPress Trac wp-trac at lists.automattic.com
Wed Oct 3 16:39:15 UTC 2012


#21459: Cleanup switch_to_blog() and restore_current_blog()
----------------------------+---------------------
 Reporter:  ryan            |       Owner:  ryan
     Type:  task (blessed)  |      Status:  closed
 Priority:  normal          |   Milestone:  3.5
Component:  Multisite       |     Version:  3.4.1
 Severity:  normal          |  Resolution:  fixed
 Keywords:  has-patch       |
----------------------------+---------------------

Comment (by nacin):

 It's the result of #19235, but worth reporting it here too.

 Before #19235, switching never worked because it relied on constants. Now,
 it calls is_main_site(). Unfortunately, is_main_site() uses
 $current_blog->blog_id rather than $blog_id or $wpdb->blogid, and
 therefore does not respond when the site is switched.

 That means that when switched, is_main_site() returns a different value
 than `is_main_site( get_current_blog_id() )`.

 That's enough to make me want to start switching $current_blog and
 $current_site, see #14190. Unfortunately, I have no idea what it'd break.

 Switching to the cryptic, seemingly nonsensical, and unnecessary-but-
 necessary `is_main_site( get_current_blog_id() )` should fix this.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21459#comment:44>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list