[wp-trac] [WordPress Trac] #16558: switch_to_blog does not properly update global $wpdb

WordPress Trac wp-trac at lists.automattic.com
Mon Feb 14 23:33:26 UTC 2011


#16558: switch_to_blog does not properly update global $wpdb
--------------------------+------------------------------
 Reporter:  divinegod     |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:  3.0.4
 Severity:  normal        |  Resolution:
 Keywords:  worksforme    |
--------------------------+------------------------------
Changes (by kawauso):

 * keywords:   => worksforme


Comment:

 Unable to reproduce on trunk. Doesn't look like wpdb.php has really
 changed since 3.0 though.

 Test code:

 {{{
 function switchblog() {
         global $wpdb;
         foreach ( $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs") as
 $blog_id ) {
                 switch_to_blog( $blog_id );
                 echo "<strong>Blog ID:</strong> $blog_id<br />";
                 foreach ( $wpdb->tables( 'blog' ) as $table => $value ) {
                         echo "$table: $value<br />";
                 }
                 echo '<p>&nbsp;</p>';
         }
         die();
 }
 add_action('init', 'switchblog');
 }}}

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


More information about the wp-trac mailing list