Make WordPress Core

Changeset 15331


Ignore:
Timestamp:
06/25/2010 04:16:06 PM (14 years ago)
Author:
ryan
Message:

Don't perform current user ops in switch_to_blog() or restore_current_blog() if init hasn't fired. Avoids wp_get_current_user() not defined error when those functions are run before init. Ops on current user prior to init are meaningless anyway. see #13934

File:
1 edited

Legend:

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

    r15315 r15331  
    408408    }
    409409 
    410     $current_user = wp_get_current_user();
    411     if ( is_object( $current_user ) )
    412         $current_user->for_blog( $blog_id );
     410    if ( ! did_action('init') ) {
     411        $current_user = wp_get_current_user(); 
     412        if ( is_object( $current_user ) )
     413            $current_user->for_blog( $blog_id );
     414    }
    413415
    414416    if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) )
     
    462464    }
    463465
    464     $current_user = wp_get_current_user();
    465     if ( is_object( $current_user ) )
    466         $current_user->for_blog( $blog_id );
     466    if ( ! did_action('init') ) {
     467        $current_user = wp_get_current_user();
     468        if ( is_object( $current_user ) )
     469            $current_user->for_blog( $blog_id );
     470    }
    467471
    468472    if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) )
Note: See TracChangeset for help on using the changeset viewer.