From 7331bf3e98e6a53a9c427905190bc85c28ed7f76 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Mon, 14 Apr 2014 08:13:10 +0000 Subject: [PATCH] Avoid stomping of bulk postdata inside the bulk_edit_posts() loop. Merges [28113] to the 3.7 branch. Reverts [27992] which did not fix it for authors and comment/ping status. props dd32, DrewAPicture. fixes #27792. Built from https://develop.svn.wordpress.org/branches/3.7@28115 git-svn-id: http://core.svn.wordpress.org/branches/3.7@27946 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/post.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index 580cf27c90..2f6ddf187e 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -411,7 +411,12 @@ function bulk_edit_posts( $post_data = null ) { } $updated = $skipped = $locked = array(); + $shared_post_data = $post_data; + foreach ( $post_IDs as $post_ID ) { + // Start with fresh post data with each iteration. + $post_data = $shared_post_data; + $post_type_object = get_post_type_object( get_post_type( $post_ID ) ); if ( !isset( $post_type_object ) || ( isset($children) && in_array($post_ID, $children) ) || !current_user_can( 'edit_post', $post_ID ) ) { @@ -460,13 +465,13 @@ function bulk_edit_posts( $post_data = null ) { $post_data['ID'] = $post_ID; $post_data['post_ID'] = $post_ID; - $translated_post_data = _wp_translate_postdata( true, $post_data ); - if ( is_wp_error( $translated_post_data ) ) { + $post_data = _wp_translate_postdata( true, $post_data ); + if ( is_wp_error( $post_data ) ) { $skipped[] = $post_ID; continue; } - $updated[] = wp_update_post( $translated_post_data ); + $updated[] = wp_update_post( $post_data ); if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts ) ) { if ( 'sticky' == $post_data['sticky'] )