Opened 18 years ago
Closed 17 years ago
#9065 closed defect (bug) (wontfix)
Can not store 0 (zero) in meta_value using update_usermeta() in user.php
| Reported by: | stevejohnson | Owned by: | jfarthing84 |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | General | Version: | 2.8.4 |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
Description
The following lines in wp-includes/user.php evaluate $meta_value passed to update_usermeta() (current line #s from trunk):
397 if (empty($meta_value)) {
398 return delete_usermeta($user_id, $meta_key);
399 }
A numerical or string zero evals as empty, resulting in the inability to store zero as a meta_value.
A better test for truly empty might be:
397 if ($meta_value == '')) {
398 return delete_usermeta($user_id, $meta_key);
399 }
Attachments (1)
Change History (18)
#2
@
18 years ago
Another thing: Everything is stored as a string (except arrays and objects), So passing (int)1 in, would result in (string)1 out, (bool)true results in (string)1 coming out.
I've found (This was with options, but the same holds for meta's) that wraping everything in an array is best array( (int)1 ); results in array( (int)1 ); coming out.
#4
follow-up:
↓ 5
@
18 years ago
Is it worth creating a patch for? If this is the way it's supposed to act, the ticket should be closed, yes?
#5
in reply to: ↑ 4
@
18 years ago
Replying to stevejohnson:
Is it worth creating a patch for? If this is the way it's supposed to act, the ticket should be closed, yes?
I do not feel that is for me to decide. If you wish to close it, then please do so.
#6
@
18 years ago
- Resolution → invalid
- Status new → closed
That was more of an "I'm new here, what should I do?" question.
Closed.
#8
@
17 years ago
- Priority lowest → normal
- Resolution invalid
- Severity trivial → normal
- Status closed → reopened
I believe this should be re-opened because, although the original poster's method as storing the value as an array may work, it creates unnecessary storage amounts storing a serialized array for one single '0'.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
I've been told that since this code section has been the same for over 2 years, it's probably best to leave it alone as changing it might break something that relies on this behavior.