Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#13903 closed defect (bug) (fixed)

WP_User object conditional failures

Reported by: filosofo's profile filosofo Owned by: filosofo's profile 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 14 years ago.

Download all attachments as: .zip

Change History (5)

#1 @filosofo
14 years ago

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

#2 @nacin
14 years ago

  • Keywords commit added

Looks good.

#3 @nacin
14 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.

#4 @nacin
14 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.