update_post_meta should add nonexistent values
|Reported by:||filosofo||Owned by:||anonymous|
Currently, if you try to use update_post_meta to update a post meta key and value that don't exist, it just returns false. This behavior is at odds with that of other update functions such as update_option, update_user_option, update_usermeta, wp_update_user, wp_update_category, and update_recently_edited, all of which will create the updated object, if it doesn't already exist.
The other updating functions, which like update_post_meta fail when the object doesn't already exist, would not typically be called when one is agnostic about the existence of the object in question: wp_update_comment and update_attached_file, e.g.; wp_update_term seems to be a possible exception.
Because update_post_meta is semantically similar to update_option and update_usermeta and like them is frequently employed in plugins, it should behave similarly.
Change History (11)
- Resolution fixed deleted
- Status changed from closed to reopened
- Version set to 2.5