Make WordPress Core


Ignore:
Timestamp:
10/01/2012 02:25:31 PM (14 years ago)
Author:
ryan
Message:

Reinit roles and the current user after switching the cache to the new blog in switch_to_blog() and restore_current_blog(). Props joostdekeijzer. fixes #21459

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/ms-blogs.php

    r22015 r22087  
    477477        $GLOBALS['blog_id'] = $new_blog;
    478478
    479         if ( did_action( 'init' ) ) {
    480                 $wp_roles->reinit();
    481                 $current_user = wp_get_current_user();
    482                 $current_user->for_blog( $new_blog );
    483         }
    484 
    485479        if ( function_exists( 'wp_cache_switch_to_blog' ) ) {
    486480                wp_cache_switch_to_blog( $new_blog );
    … …  
    504498        }
    505499
     500        if ( did_action( 'init' ) ) {
     501                $wp_roles->reinit();
     502                $current_user = wp_get_current_user();
     503                $current_user->for_blog( $new_blog );
     504        }
     505
    506506        do_action( 'switch_blog', $new_blog, $prev_blog_id );
    507507        $GLOBALS['switched'] = true;
    … …  
    537537        $GLOBALS['blog_id'] = $blog;
    538538        $GLOBALS['table_prefix'] = $wpdb->prefix;
    539 
    540         if ( did_action( 'init' ) ) {
    541                 $wp_roles->reinit();
    542                 $current_user = wp_get_current_user();
    543                 $current_user->for_blog( $blog );
    544         }
    545539
    546540        if ( function_exists( 'wp_cache_switch_to_blog' ) ) {
    … …  
    563557                        wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) );
    564558                }
     559        }
     560
     561        if ( did_action( 'init' ) ) {
     562                $wp_roles->reinit();
     563                $current_user = wp_get_current_user();
     564                $current_user->for_blog( $blog );
    565565        }
    566566
Note: See TracChangeset for help on using the changeset viewer.