[wp-trac] [WordPress Trac] #20845: wp_set_current_user( null, "name") does not work when $current_user is already 0

WordPress Trac noreply at wordpress.org
Thu Oct 8 18:05:49 UTC 2015


#20845: wp_set_current_user( null, "name") does not work when $current_user is
already 0
-------------------------------------+---------------------------
 Reporter:  bobbingwide              |       Owner:  boonebgorges
     Type:  defect (bug)             |      Status:  closed
 Priority:  normal                   |   Milestone:  4.4
Component:  Users                    |     Version:  3.3.2
 Severity:  normal                   |  Resolution:  fixed
 Keywords:  has-patch needs-testing  |     Focuses:
-------------------------------------+---------------------------

Comment (by bobbingwide):

 Replying to [comment:15 boonebgorges]:
 > Thanks for the patch, bobbingwide. The strict check you've suggested
 will force a user switch in the following case:
 >
 > {{{
 > wp_set_current_user( 3 );
 > wp_set_current_user( '3' );
 > }}}
 >
 > I don't think we want that. So we'll be a bit more precise and check for
 `$id === null`, which is how the `$id` bypass is supposed to work anyway.

 Good spot. Will there need to be a test where?
 {{{
 ID=3 user_login="three"
 ID=4 user_login="3"
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/20845#comment:17>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list