Make WordPress Core

Opened 5 years ago

#48580 new defect (bug)

Update status in save_post hooks always true in WordPress 5.0

Reported by: oxibug's profile oxibug Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.2.4
Component: Posts, Post Types Keywords:
Focuses: Cc:

Description

I think this issue shown after integration of Gutenberg editor, The {save_post} and {save_POST_TYPE} hooks always triggers {$update} as TRUE.

I made some tests, The {$update} is TRUE on saving the post for the first time and on updating also, it's always true.

<?php
add_action( 'save_post', array( $this, 'cpt_metas_save' ), 10, 3 );

public function cpt_metas_save( $post_ID, $post, $update ) {        
    $db_values = array(
        'is_new'    => 'No'
    );

    if( $update ) {
        /* Saving New Post trigger this -- always {Yes} */
        $db_values['is_new'] = 'Yes';
    }
    else {
        $db_values['is_new'] = 'No';
    }

    /* Connect to IBM Server */
    
    /* Update DB */
    update_post_meta( $post_ID, 'postmetas_save_test', wp_unslash( $db_values ) );
}

Change History (0)

Note: See TracTickets for help on using tickets.