Make WordPress Core


Ignore:
Timestamp:
10/08/2015 05:28:34 PM (10 years ago)
Author:
boonebgorges
Message:

Allow a null id to do a name lookup in wp_set_current_user().

Previously, the name fallback was failing in the case where the current user
was 0, due to a loose comparison between 0 (the current user) and null (the
value that is used to trigger the name fallback).

Props bobbingwide.
Fixes #20845.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/pluggable.php

    r34924 r34947  
    2727    global $current_user;
    2828
    29     if ( isset( $current_user ) && ( $current_user instanceof WP_User ) && ( $id == $current_user->ID ) )
     29    // If `$id` matches the user who's already current, there's nothing to do.
     30    if ( isset( $current_user )
     31        && ( $current_user instanceof WP_User )
     32        && ( $id == $current_user->ID )
     33        && ( null !== $id )
     34    ) {
    3035        return $current_user;
     36    }
    3137
    3238    $current_user = new WP_User( $id, $name );
Note: See TracChangeset for help on using the changeset viewer.