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

git-svn-id: http://core.svn.wordpress.org/trunk@22087 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Ryan Boren 2012-10-01 14:25:31 +00:00
parent 9c9ecb315e
commit 75e64cface
2 changed files with 16 additions and 12 deletions

View File

@ -263,6 +263,10 @@ class WP_Comment_Query {
$approved = "comment_approved = '0'";
elseif ( 'approve' == $status )
$approved = "comment_approved = '1'";
elseif ( 'all' == $status )
$approved = "( comment_approved = '0' OR comment_approved = '1' )";
elseif ( 'full' == $status )
$approved = '0 = 0';
elseif ( ! empty( $status ) )
$approved = $wpdb->prepare( "comment_approved = %s", $status );
else

View File

@ -476,12 +476,6 @@ function switch_to_blog( $new_blog, $deprecated = null ) {
$prev_blog_id = $GLOBALS['blog_id'];
$GLOBALS['blog_id'] = $new_blog;
if ( did_action( 'init' ) ) {
$wp_roles->reinit();
$current_user = wp_get_current_user();
$current_user->for_blog( $new_blog );
}
if ( function_exists( 'wp_cache_switch_to_blog' ) ) {
wp_cache_switch_to_blog( $new_blog );
} else {
@ -503,6 +497,12 @@ function switch_to_blog( $new_blog, $deprecated = null ) {
}
}
if ( did_action( 'init' ) ) {
$wp_roles->reinit();
$current_user = wp_get_current_user();
$current_user->for_blog( $new_blog );
}
do_action( 'switch_blog', $new_blog, $prev_blog_id );
$GLOBALS['switched'] = true;
@ -537,12 +537,6 @@ function restore_current_blog() {
$GLOBALS['blog_id'] = $blog;
$GLOBALS['table_prefix'] = $wpdb->prefix;
if ( did_action( 'init' ) ) {
$wp_roles->reinit();
$current_user = wp_get_current_user();
$current_user->for_blog( $blog );
}
if ( function_exists( 'wp_cache_switch_to_blog' ) ) {
wp_cache_switch_to_blog( $blog );
} else {
@ -564,6 +558,12 @@ function restore_current_blog() {
}
}
if ( did_action( 'init' ) ) {
$wp_roles->reinit();
$current_user = wp_get_current_user();
$current_user->for_blog( $blog );
}
do_action( 'switch_blog', $blog, $prev_blog_id );
// If we still have items in the switched stack, consider ourselves still 'switched'