[wp-trac] [WordPress Trac] #12414: delete_post_meta not working correctly when used with save_post
WordPress Trac
wp-trac at lists.automattic.com
Sat Feb 27 17:32:10 UTC 2010
#12414: delete_post_meta not working correctly when used with save_post
-------------------------------+--------------------------------------------
Reporter: studiograsshopper | Owner:
Type: defect (bug) | Status: new
Priority: high | Milestone: 3.0
Component: General | Version: 3.0
Severity: major | Keywords: needs-patch
-------------------------------+--------------------------------------------
I think this is a bug because the same code works fine in 2.9.2.
I'm using add_metabox hooked to admin_menu to manage certain custom fields
in the Post and Page Editor. A further function, hooked to save_post,
gathers the $_POST items from my metabox, sanitises the data and then
adds, updates or deletes postmeta using add_post_meta(),
update_post_meta() and delete_post_meta() as required. If a metabox is
empty, eg when the user blanks out a metabox field, the function uses
this:
delete_post_meta($post->ID, $key);
to delete the postmeta meta_key from the db where the meta_value is empty.
The problem is that delete_post_meta() is no longer working under the
latest nightly build (but works fine in WP 2.9.2). No errors are thrown,
but the postmeta meta_key is not removed from the db.
As mentioned, this same code works perfectly on WP 2.9.2. I did a search
on trac to see if I could find any tickets relating to this, but either my
searching was ineffective, or no one else has reported this.
add_post_meta() and update_post_meta() work as expected.
This bug affects several plugins and themes which use this kind of
functionality.
For the sake of completeness, I've attached one of the files from a plugin
of mine which is affected by this.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/12414>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list