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

WordPress Trac wp-trac at lists.automattic.com
Wed Sep 5 15:49:48 UTC 2012


#21459: Cleanup switch_to_blog() and restore_current_blog()
-------------------------+-----------------------
 Reporter:  ryan         |       Owner:  ryan
     Type:  enhancement  |      Status:  reopened
 Priority:  normal       |   Milestone:  3.5
Component:  Multisite    |     Version:  3.4.1
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |
-------------------------+-----------------------
Changes (by joostdekeijzer):

 * cc: joost@… (added)


Comment:

 Since [21485] `current_user_can_for_blog` and `get_blog_option` interfere
 resulting in unexpected results.

 The changes to `current_user_can_for_blog` seem to be the cause...

 For example, in below code `$sort_array` will contain only the name of the
 'current' blog (the blog the user initially navigated to):
 {{{
 // code taken from my network-shared-media plugin (could probably be
 optimized for speed...)
 foreach ( (array) $blogs as $details ) {
         if ( !current_user_can_for_blog( $details['blog_id'],
 'upload_files') ) {
                 continue;
         }

         $details['name'] = get_blog_option( $details['blog_id'],
 'blogname' );
         $this->blogs[] = $details;
         $sort_array[] = strtolower ( $details['name'] );
 }
 }}}

 I will try to write a testcase later this week

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


More information about the wp-trac mailing list