[wp-trac] [WordPress Trac] #21601: Introduce WP_User::has_prop_val() magic method

WordPress Trac wp-trac at lists.automattic.com
Thu Aug 16 01:19:44 UTC 2012


#21601: Introduce WP_User::has_prop_val() magic method
------------------------------------------------+--------------------------
 Reporter:  wpsmith                             |       Owner:
     Type:  defect (bug)                        |      Status:  new
 Priority:  normal                              |   Milestone:  Awaiting
Component:  Users                               |  Review
 Severity:  normal                              |     Version:
 Keywords:  has-patch 2nd-opinion dev-feedback  |  Resolution:
------------------------------------------------+--------------------------

Comment (by scribu):

 This comes down to an inconsistency in PHP, where `__isset()` is called by
 both isset() and empty():

 {{{
 $user->user_url = '';

 isset( $user->user_url );   // true
 !empty( $user->user_url );  // false
 }}}

 For explicit calls, you have to be more verbose:

 {{{
 $user->user_url = '';

 $user->has_prop( 'user_url' );  // true

 $user->has_prop( 'user_url' ) && !empty( $user->get( 'user_url' );  //
 true
 }}}

 So, has_prop_val() sort of makes sense, but drop `__hasval()`.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21601#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list