[wp-trac] [WordPress Trac] #14190: switch_to_blog() should affect $current_blog global

WordPress Trac wp-trac at lists.automattic.com
Sat Jul 3 21:48:49 UTC 2010

#14190: switch_to_blog() should affect $current_blog global
 Reporter:  filosofo      |       Owner:  filosofo      
     Type:  defect (bug)  |      Status:  new           
 Priority:  normal        |   Milestone:  Future Release
Component:  Multisite     |     Version:  3.0           
 Severity:  normal        |    Keywords:  needs-patch   
 Currently, `switch_to_blog()` does not change the `$current_blog` global
 set of variables.  So functions such as `is_main_site()` will continue to
 use the previous set blog id.

 So for example if you switch to another blog while acting as a site admin
 to flush rewrite rules on a non-main blog, the non-main blog gets the
 main-blog-specific rewrite rules.

 My general suggestion is that we move `$current_blog` into a function like
 `get_current_blog` and not count on the global to be populated correctly,
 then replace `$current_blog` global variable references with calls to
 `get_current_blog`, which will handle the current blog situation

Ticket URL: <http://core.trac.wordpress.org/ticket/14190>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software

More information about the wp-trac mailing list