From 233750f88fffb1402c3b216766b463b23f33bcd1 Mon Sep 17 00:00:00 2001 From: Mallory Adams Date: Mon, 30 Mar 2020 14:06:28 -0400 Subject: [PATCH] Fix bug preventing previewing posts authored by other users Bug description: The author of a post can preview changes to their own published posts, but other users see the content of the published post when previewing. This is due to checking for the autosaves of `$query_args->post_author` instead of the autosaves of `get_current_user_id()`. Steps to reproduce: 1. Log in as user A 2. Create a new post, press "Publish" 3. Log in as user B 4. Visit the edit page for the post that was just created 5. Add to the post's content (without pressing "Update") 6. Click "Preview" Expected behaviour: The content added by user B appears in the preview. Actual behaviour: The content added by user B doesn't appear in the preview of the post. --- modules/custom-status/custom-status.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/custom-status/custom-status.php b/modules/custom-status/custom-status.php index 34aced218..f3ee0231c 100644 --- a/modules/custom-status/custom-status.php +++ b/modules/custom-status/custom-status.php @@ -1508,7 +1508,7 @@ public function fix_preview_link_part_two( $permalink, $post, $sample ) { * @see https://github.com/Automattic/Edit-Flow/issues/513 */ public function fix_preview_link_part_three( $preview_link, $query_args ) { - if ( $autosave = wp_get_post_autosave( $query_args->ID, $query_args->post_author ) ) { + if ( $autosave = wp_get_post_autosave( $query_args->ID, get_current_user_id() ) ) { foreach ( array_intersect( array_keys( _wp_post_revision_fields( $query_args ) ), array_keys( _wp_post_revision_fields( $autosave ) ) ) as $field ) { if ( normalize_whitespace( $query_args->$field ) != normalize_whitespace( $autosave->$field ) ) { // Pass through, it's a personal preview.