[wp-trac] [WordPress Trac] #24255: WP_User::__set doesn't persist custom fields as it claims

WordPress Trac noreply at wordpress.org
Fri May 3 03:17:42 UTC 2013


#24255: WP_User::__set doesn't persist custom fields as it claims
--------------------------+-----------------------------
 Reporter:  quickshiftin  |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Users         |    Version:  3.5.1
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 Looking through `WP_User` in version 3.5.1 (verified against svn trunk
 too), the magic methods {{{ __get }}} and {{{ __set }}} supposedly read
 and write from custom fields, per their comment blocks.
 {{{
         /**
          * Magic method for accessing custom fields
          *
          * @since 3.3.0
          */
         function __get( $key ) {
         // ...

         /**
          * Magic method for setting custom fields
          *
          * @since 3.3.0
          */
         function __set( $key, $value ) {
         // ...
 }}}
 And sure enough, if you look through the method bodies {{{ __get }}} will
 make a call to {{{ get_user_meta }}}

         {{{ $value = get_user_meta( $this->ID, $key, true ); }}}

 However reading through the body of {{{ __set }}}, it never calls {{{
 add_user_meta }}} or {{{ update_user_meta }}}, but has the misleading
 comment that it's "for setting custom fields...".

 Seems to me like it's missing a critical line:

         {{{ update_user_meta($this->ID, $key, $value); }}}

 Am I missing something, or is this a bug?

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/24255>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list