Opened 15 years ago
Closed 15 years ago
#13362 closed defect (bug) (fixed)
setup_userdata() should set the userdata globals even if the current user is 0
Reported by: | mdawaffe | Owned by: | |
---|---|---|---|
Milestone: | 3.0 | Priority: | normal |
Severity: | normal | Version: | 3.0 |
Component: | General | Keywords: | has-patch |
Focuses: | Cc: |
Description
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?
Attachments (1)
Change History (2)
Note: See
TracTickets for help on using
tickets.
(In [14573]) Setup user globals for user id 0. Props mdawaffe. fixes #13362