[wp-trac] [WordPress Trac] #13362: setup_userdata() should set the userdata globals even if the current user is 0

WordPress Trac wp-trac at lists.automattic.com
Tue May 11 22:59:02 UTC 2010


#13362: setup_userdata() should set the userdata globals even if the current user
is 0
--------------------------+-------------------------------------------------
 Reporter:  mdawaffe      |       Owner:           
     Type:  defect (bug)  |      Status:  new      
 Priority:  normal        |   Milestone:  3.0      
Component:  General       |     Version:  3.0      
 Severity:  normal        |    Keywords:  has-patch
--------------------------+-------------------------------------------------
 == Problem ==

 When calling {{{wp_set_current_user( 0 )}}}, {{{setup_userdata()}}}
 returns before clearing the userdata globals.  Since we still rely on
 those globals in several places, returning before clearing has unexpected
 consequences.

 {{{setup_userdata()}}} should clear those globals if called for an empty
 user object.

 == Example ==
 {{{
 wp_set_current_user( 1 );
 wp_set_current_user( 0 );
 $post_id = wp_insert_post( 'post_author=0' );
 $post = get_post( $post_id ); // This post has an author!
 }}}

 {{{wp_insert_post()}}} falls back to {{{$GLOBALS['user_ID']}}} when
 {{{post_author}}} is empty.

 This particular example is more likely to crop up now that we have awesome
 support for custome post types, but there are several places where we rely
 on these lame userdata globals.

 Marking as 3.0, but is it too late?

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/13362>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list