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: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 5.9 | Priority: | normal |
Severity: | normal | Version: | 4.9 |
Component: | Posts, Post Types | Keywords: | good-first-bug 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)
Change History (11)
This ticket was mentioned in Slack in #core by peterwilsoncc. View the logs.
3 years ago
#2
@
3 years ago
- Component changed from Administration to Posts, Post Types
- Keywords needs-patch good-first-bug added
#4
@
3 years ago
- Owner set to guillaumeturpin
- Status changed from new to assigned
Assigning to mark the good-first-bug as claimed.
#6
@
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
@
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.
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.