Make WordPress Core

Opened 7 years ago

Closed 3 years ago

#42446 closed defect (bug) (fixed)

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

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


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 3 years ago.
42446.2.diff (717 bytes) - added by guillaumeturpin 3 years ago.
Removed the conditional statement, and wrapped your solution into 3 lines for readability

Download all attachments as: .zip

Change History (11)

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

3 years ago

#2 @peterwilsoncc
3 years 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
3 years ago

HI @peterwilsoncc

I will check this out

#4 @audrasjb
3 years ago

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

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

#5 @guillaumeturpin
3 years ago

Update post with bulk edit now update the edit last user

#6 @audrasjb
3 years 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.

3 years ago

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

#7 @audrasjb
3 years ago

  • Milestone changed from Awaiting Review to 5.9

Looks good to me, thanks!

Let's move this ticket for 5.9 consideration.

#8 @audrasjb
3 years ago

  • Keywords 2nd-opinion removed

The patch still applies cleanly against trunk and fixes the issue.
Marking for commit consideration.

#9 @davidbaumwald
3 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 52141:

Posts, Post Types: Update _edit_last meta when posts are edited in bulk.

When posts are edited in bulk, the _edit_last meta was not updated for each post. This change adds a call to update the _edit_last meta to the current user ID for each post the is updated.

Props calebwoodbridge, peterwilsoncc, guillaumeturpin, audrasjb.
Fixes #42446.

Note: See TracTickets for help on using tickets.