Post Revision history displays the incorrect author
|Reported by:||mdawaffe||Owned by:||westi|
|Cc:||d@…, aaroncampbell, adamsilverstein@…, erick@…, ian_dunn@…|
Steps to reproduce:
- Create and Publish a new post as user admin.
- Edit that post and Update as user mdawaffe.
- View revision history for that post. Note that the revisions are attributed to the wrong authors.
The revision's post_author is currently being set to whoever edited the post away from the state represented by that revision row. It should be set to the person who edited the post *to* the state represented by that row.
This bug has been around since the introduction of post revisions.
To fix for future posts, I can think of two options.
- We should be able to pull the correct author for a new revision row from the _edit_lock/_edit_last post meta of the post (as long as we grab that before we update the post row).
- Currently, when a post is updated, revisions first grabs a copy of the current state of the post, stores it as a revision, then updates the post row. To fix this bug, we could instead update the post row first then store a copy of that new state as a revision. That would mean the most recent revision for all posts would be a duplicate of the actual post.
Option 2 would be cleaner code, option 1 would be cleaner data.
To fix for existing posts, we need to go through each post and fix each revision. That's incredibly expensive to do on upgrade, so I suggest doing it per post on the fly when the post edit screen or post revisions screen is loaded.
If we fix on the fly, we have to be able to keep track of which posts/revisions have been fixed and which haven't. We could track that with:
- An option that is set on upgrade with a timestamp. Compare post_modified to that timestamp. This seems fragile to me since I bet there are plugins that override post_modifed.
- Post meta. Easy, but adds one post meta per post just to fix a lame bug.
- Bump the menu_order of each fixed revision row from 0 -> 1. (A version number for the revisioning system :)). Hacky.
I like 3: menu_order.
We could also leave everything as is, allow the data to be wrong, and "fix" it on display or even in get_post().
Aside: While we're in there, we may want to "fix" revisions' post_modified columns. Currently, post_modified is identical to post_date, which is the time the post was put into the state represented by the revision. We could make post_modified the time the post was edited away from the state represented by the revision.
Change History (121)
- Cc aaroncampbell added
- Keywords 3.4-early removed
- Milestone changed from Future Release to 3.6
- Keywords revisions-3.6 added
- Owner set to westi
- Status changed from new to accepted
- Summary changed from Post Revision history displays the incorrect author to on post update, ensure most recent revision data matches stored post data; fix old revisions
- Type changed from defect (bug) to enhancement
- Summary changed from on post update, ensure most recent revision data matches stored post data; fix old revisions to Post Revision history displays the incorrect author
- Type changed from enhancement to defect (bug)
- Resolution set to fixed
- Status changed from accepted to closed
- Resolution fixed deleted
- Status changed from closed to reopened