[wp-trac] [WordPress Trac] #13267: get_metadata() is breaking assoc arrays

WordPress Trac wp-trac at lists.automattic.com
Wed May 5 21:13:24 UTC 2010

#13267: get_metadata() is breaking assoc arrays
 Reporter:  apeatling     |       Owner:  ryan
     Type:  defect (bug)  |      Status:  new 
 Priority:  high          |   Milestone:  3.0 
Component:  Database      |     Version:  3.0 
 Severity:  blocker       |    Keywords:      
 I'm doing some work with the new update/delete/get_user_meta() functions
 and noticed that associative arrays are breaking. The returned array from
 get_user_meta() is always returning on a level below where it should be.
 The problem is compounded if you try and fetch existing values and then

 From what I can see, the issue stems from the get_metadata() function.

 Here's some code that highlights the problem, activate it and refresh the
 page a few times:

 Plugin Name: Usermeta Test

 function usermeta_test() {
         global $current_user;

         if ( empty( $current_user->ID ) )
                 return false;

         $old_from_db = get_user_meta( $current_user->ID, 'um_test_old' );
         $new_from_db = get_usermeta( $current_user->ID, 'um_test_new' );

         $old_from_db['foo'][] = true;
         $new_from_db['foo'][] = true;

         update_user_meta( $current_user->ID, 'um_test_old', $old_from_db
         update_usermeta( $current_user->ID, 'um_test_new', $new_from_db );

         var_dump( $old_from_db, $new_from_db );
 add_action( 'init', 'usermeta_test' );

 I don't have a patch yet, I wanted to get the ticket up first.

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

More information about the wp-trac mailing list