#13088 closed defect (bug) (fixed)
update_usermeta() and update_user_meta() behave differently
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | 3.0 | Priority: | normal |
| Severity: | major | Version: | 3.0 |
| Component: | Users | Keywords: | meta |
| Focuses: | Cc: |
Description
Problem
The old function, update_usermeta(), deletes the meta row if the passed value is empty.
The new function, update_user_meta(), goes through the meta API function update_metadata(), which does not delete the meta row if the passed value is empty.
update_usermeta() is marked as deprecated, but, because of this difference, is not an alias of update_user_meta(). Instead, the function is fully defined in deprecated.php.
Impact
update_user_option() used to go through update_usermeta() and now goes through update_user_meta(), so it's behavior has changed.
Example
Multisite signups are wonky: source:/trunk/wp-includes/ms-functions.php@14190#L789
Ideas
Switch update_user_option() back to update_usermeta().
Add delete_user_meta() logic to update_user_option().
Use delete_user_meta() where needed instead.
Attachments (2)
Change History (11)
#2
@
16 years ago
- Milestone changed from Unassigned to 3.0
People may deliberately use array() to store empty data, knowing that other values will cause the meta row to be deleted. We've seen that in other situations.
#3
follow-up:
↓ 4
@
16 years ago
I kept forgetting to move over those checks in wpmu_new_user.
Maybe we just do:
if ( ! is_array( $newvalue ) && empty( $newvalue ) ) // delete
#4
in reply to:
↑ 3
@
16 years ago
Replying to nacin:
Maybe we just do:
if ( ! is_array( $newvalue ) && empty( $newvalue ) ) // delete
Maybe if ( is_scalar( $newvalue ) && empty( $newvalue ) ) ? Empty objects are dealt with the same way as empty arrays.
13088.diff
Switches wpmu_create_user() to use delete_user_option().
Adds delete_user_meta() logic to update_user_option(). This simple test isn't 100% backward compatible since update_usermeta() serializes the value before doing the empty() check. So empty arrays don't cause the row to be deleted in update_usermeta(), but they do cause the row to be deleted in the above patched version of update_user_option().
Untested :)