[wp-trac] [WordPress Trac] #7018: update_post_meta should add nonexistent values

WordPress Trac wp-trac at lists.automattic.com
Wed May 21 23:51:05 GMT 2008


#7018: update_post_meta should add nonexistent values
----------------------+-----------------------------------------------------
 Reporter:  filosofo  |       Owner:  anonymous       
     Type:  defect    |      Status:  new             
 Priority:  normal    |   Milestone:  2.6             
Component:  General   |     Version:                  
 Severity:  normal    |    Keywords:  update_post_meta
----------------------+-----------------------------------------------------
 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.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/7018>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list