WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#13903 closed defect (bug) (fixed)

WP_User object conditional failures

Reported by: filosofo Owned by: filosofo
Milestone: 3.0.1 Priority: normal
Severity: normal Version: 3.0
Component: Users Keywords: has-patch commit
Focuses: Cc:

Description

A number of places check whether a user object has instantiated the data of an actual user by either checking whether the user object is empty or falsely. Both checks will fail to come to the correct conclusion because $user is an object that has default properties and methods.

$user = new WP_User( 0 ); // not a user's ID

var_dump( empty( $user ) ); // false!
var_dump( ! $user ); // false !
var_dump( empty( $user->ID ) ); // true; that's more like it

Attachments (1)

user-object-logic-check-failures.13903.diff (1.7 KB) - added by filosofo 4 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 filosofo4 years ago

  • Owner set to filosofo
  • Status changed from new to accepted

comment:2 nacin4 years ago

  • Keywords commit added

Looks good.

comment:3 nacin4 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

(In [15403]) Fix checking for whether WP_User object is actually a user. props filosofo, fixes #13903 for 3.0.

comment:4 nacin4 years ago

(In [15404]) Fix checking for whether WP_User object is actually a user. props filosofo, fixes #13903 for trunk.

Note: See TracTickets for help on using tickets.