Make WordPress Core

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#13903 closed defect (bug) (fixed)

WP_User object conditional failures

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

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 16 years ago.

Download all attachments as: .zip

Change History (5)

#1 @filosofo
16 years ago

  • Owner set to filosofo
  • Status newaccepted

#2 @nacin
16 years ago

  • Keywords commit added

Looks good.

#3 @nacin
16 years ago

  • Resolutionfixed
  • Status acceptedclosed

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

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