WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 4 weeks ago

#42446 assigned defect (bug)

Bulk edits don't update "last edited by..." which user

Reported by: calebwoodbridge Owned by: guillaumeturpin
Milestone: 5.9 Priority: normal
Severity: normal Version: 4.9
Component: Posts, Post Types Keywords: good-first-bug 2nd-opinion has-patch
Focuses: administration Cc:

Description

On a multi-author site, I made some bulk edits to some posts' categories. These posts were previously created and last updated by other users.

In the editor for the individual posts, it now says "Last updated by [previous user] on [date and time I made the changes]", which is incorrect. It looks like the bulk editor doesn't update which user last edited a post, though it does update the last modified time.

I would expect it to say "Last updated by [my username]..." - which is what it does if I quick edit an individual post, or change the categories on the full post edit page.

I've found the same behaviour on two different sites, and both on standard pages and categories, and on a custom post type and custom taxonomy.

Attachments (2)

42446.1.diff (732 bytes) - added by guillaumeturpin 4 weeks ago.
42446.2.diff (717 bytes) - added by guillaumeturpin 4 weeks ago.
Removed the conditional statement, and wrapped your solution into 3 lines for readability

Download all attachments as: .zip

Change History (9)

This ticket was mentioned in Slack in #core by peterwilsoncc. View the logs.


4 weeks ago

#2 @peterwilsoncc
4 weeks ago

  • Component changed from Administration to Posts, Post Types
  • Keywords needs-patch good-first-bug added

Hello and a belated welcome to trac!

I'm sorry it's take a while for you to hear back but this ticket was discussed earlier today in a triage session.

During the triage session we were able to reproduce the bug and narrow down the cause: the function bulk_edit_posts() is used for bulk updates but fails to update the meta data to indicate who last modified the post.

To resolve this technically, the following code needs to be run for each post that is updated: update_post_meta( $post_ID, '_edit_last', get_current_user_id() );

I've moved this to the Posts component and made a few other administrative changes.

Thanks for your patience.

#3 @guillaumeturpin
4 weeks ago

HI @peterwilsoncc

I will check this out

#4 @audrasjb
4 weeks ago

  • Owner set to guillaumeturpin
  • Status changed from new to assigned

Assigning to mark the good-first-bug as claimed.

#5 @guillaumeturpin
4 weeks ago

Update post with bulk edit now update the edit last user

#6 @audrasjb
4 weeks ago

  • Keywords 2nd-opinion has-patch added; needs-patch removed

Thanks for the quick patch @guillaumeturpin!

$post_id = wp_update_post( $post_data );
if ( update_post_meta( $post_id, '_edit_last', get_current_user_id() ) ) {
    $updated[] = $post_id;
}

Just wondering if we really need/want to place $updated[] = $post_id; within a conditional statement.

Maybe the code below would be enough and more straightforward?

$updated[] = $post_id = wp_update_post( $post_data );
update_post_meta( $post_id, '_edit_last', get_current_user_id() ) );

By the way, the patch works fine on my side.

@guillaumeturpin
4 weeks ago

Removed the conditional statement, and wrapped your solution into 3 lines for readability

#7 @audrasjb
4 weeks ago

  • Milestone changed from Awaiting Review to 5.9

Looks good to me, thanks!

Let's move this ticket for 5.9 consideration.

Note: See TracTickets for help on using tickets.