Customize: Prevent post_content and post_name from being modified when trashing customize_changeset posts.

See #30937.
Fixes #38719.

Built from https://develop.svn.wordpress.org/trunk@39180


git-svn-id: http://core.svn.wordpress.org/trunk@39120 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2016-11-09 05:45:32 +00:00
parent 3a449ea543
commit 5b633c548e
2 changed files with 43 additions and 3 deletions

View File

@ -2549,7 +2549,7 @@ function _wp_customize_include() {
* @param WP_Post $changeset_post Changeset post object.
*/
function _wp_customize_publish_changeset( $new_status, $old_status, $changeset_post ) {
global $wp_customize;
global $wp_customize, $wpdb;
$is_publishing_changeset = (
'customize_changeset' === $changeset_post->post_type
@ -2600,7 +2600,47 @@ function _wp_customize_publish_changeset( $new_status, $old_status, $changeset_p
* and thus garbage collected.
*/
if ( ! wp_revisions_enabled( $changeset_post ) ) {
wp_trash_post( $changeset_post->ID );
$post = $changeset_post;
$post_id = $changeset_post->ID;
/*
* The following re-formulates the logic from wp_trash_post() as done in
* wp_publish_post(). The reason for bypassing wp_trash_post() is that it
* will mutate the the post_content and the post_name when they should be
* untouched.
*/
if ( ! EMPTY_TRASH_DAYS ) {
wp_delete_post( $post_id, true );
} else {
/** This action is documented in wp-includes/post.php */
do_action( 'wp_trash_post', $post_id );
add_post_meta( $post_id, '_wp_trash_meta_status', $post->post_status );
add_post_meta( $post_id, '_wp_trash_meta_time', time() );
$old_status = $post->post_status;
$new_status = 'trash';
$wpdb->update( $wpdb->posts, array( 'post_status' => $new_status ), array( 'ID' => $post->ID ) );
clean_post_cache( $post->ID );
$post->post_status = $new_status;
wp_transition_post_status( $new_status, $old_status, $post );
/** This action is documented in wp-includes/post.php */
do_action( 'edit_post', $post->ID, $post );
/** This action is documented in wp-includes/post.php */
do_action( "save_post_{$post->post_type}", $post->ID, $post, true );
/** This action is documented in wp-includes/post.php */
do_action( 'save_post', $post->ID, $post, true );
/** This action is documented in wp-includes/post.php */
do_action( 'wp_insert_post', $post->ID, $post, true );
/** This action is documented in wp-includes/post.php */
do_action( 'trashed_post', $post_id );
}
}
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.7-beta2-39179';
$wp_version = '4.7-beta2-39180';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.