[wp-trac] [WordPress Trac] #25023: WordPress 3.6 deleting data on custom post meta

WordPress Trac noreply at wordpress.org
Wed Aug 28 10:26:03 UTC 2013


#25023: WordPress 3.6 deleting data on custom post meta
-------------------------------------+------------------------------
 Reporter:  cdwharton                |       Owner:
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  Awaiting Review
Component:  Administration           |     Version:  3.6
 Severity:  critical                 |  Resolution:
 Keywords:  reporter-feedback close  |
-------------------------------------+------------------------------
Changes (by c3mdigital):

 * keywords:  reporter-feedback => reporter-feedback close


Comment:

 I can not reproduce this following the reporters exact steps and upgrading
 from 3.5.2 to 3.6.  The provided code is slightly flawed but it does and
 should always work.

 Instead of calling global $post he should be getting the $post object from
 the function in both the save and add_meta_box callbacks.  Maybe another
 plugin is somehow polluting global $post?  and when the edit page loads
 the meta boxes are empty because the post ID is wrong?  Just a thought but
 that is the only thing I can think of.

 He should also be doing a comparison on the saved meta vs the $_POST 'd
 meta and only call update_post_meta if something has changed.

 Reporter,
 Please test again with no plugins activated and using one of the default
 themes.  Additionally to test my theory test your current configuration
 that is causing this issue and add the following code somewhere.


 {{{
 add_action( 'save_post', function( $post_id, $post_object ) {
       var_dump( $post_object->ID );
       global $post;
       var_dump( $post->ID );
       wp_die();
 }. 10, 2 );
 }}}

 Open a page with the metabox contents and hit publish and compare the 2
 post ids to see if they match.

--
Ticket URL: <http://core.trac.wordpress.org/ticket/25023#comment:16>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list