#13267 closed defect (bug) (invalid)
get_metadata() is breaking assoc arrays
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | Priority: | high | |
Severity: | blocker | Version: | 3.0 |
Component: | Database | Keywords: | |
Focuses: | Cc: |
Description
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 update.
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:
<?php /* 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.
Change History (3)
Note: See
TracTickets for help on using
tickets.
New and old vars are backwards in the above example, but it still works fine.