Opened 14 years ago
Closed 13 years ago
#3139 closed defect (bug) (fixed)
groups_update_groupmeta() should accept 0 as meta value
Reported by: | calvin_42 | Owned by: | |
---|---|---|---|
Milestone: | 1.6 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Groups | Keywords: | |
Cc: |
Description
Hi there!
groups_update_groupmeta() and bp_blogs_update_blogmeta() contain the following lines :
if (empty($meta_value)) { return groups_delete_groupmeta( $group_id, $meta_key ) }
So if I want to record the meta value 0 I have to do an INSERT value using directly $wpdb. I don't understand the limitation.
FYI WP update_metadata() doesn't have anymore this kind of limitation (deprecated update_usermeta() had).
Change History (4)
#2
@
14 years ago
- Milestone changed from Awaiting Review to 1.4
Boone and I discussed this on IRC and decided this change is a bit late for BP 1.3 as it would require to audit all the core code, and could cause unexpected behaviour with plugins. In any case, when BP switches to post types, our meta functions will likely become wrappers for post meta, which will fix this problem by getting rid of it :)
#3
@
13 years ago
- Severity set to normal
I've done a sweep through all core uses of groups_get_groupmeta(), to make sure that none of them would be messed up if we allowed the return value of groups_get_groupmeta() to be 0 rather than an empty string. There was only one place where, in a few bizarre edge cases, a problem might have arisen (having to do with the creation of groups, and checking '' ==
instead of empty()
.
The greater risk is in terms of plugins using groups_update_groupmeta() and groups_get_groupmeta(), but even then it's very much an edge case, since there will only be a problem if a plugin is doing strict type checking (like '' === groups_get_groupmeta()
)
Let's keep an eye on this as the dev cycle proceeds. I don't anticipate any problems.
I noticed this just the other day as well. I agree that allowing 0 is better. Anyone have an argument in the other direction, or can I go ahead and make the change?