[wp-trac] [WordPress Trac] #63446: Preview Changes show wrong revisions
WordPress Trac
noreply at wordpress.org
Wed May 14 08:11:09 UTC 2025
#63446: Preview Changes show wrong revisions
---------------------------+-----------------------------
Reporter: daomapsieucap | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Autosave | Version: 6.8
Severity: normal | Keywords:
Focuses: |
---------------------------+-----------------------------
Since WordPress 6.8, the wp_get_post_autosave() function has been updated
to use WP_Query instead of a direct SELECT query. However, this change
introduces unexpected behavior when retrieving the autosave revision,
particularly when using the Preview Changes button on a Page.
These following are 2 MySQL query I got
- Before WordPress 6.8
`SELECT * FROM wp_posts WHERE post_parent = 20 AND post_type = 'revision'
AND post_status = 'inherit' AND post_name = '20-autosave-v1' ORDER BY
post_date DESC LIMIT 1`
--> Returns page with ID = 945 (the correct one).
- After WordPress 6.8
`SELECT wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.ID = 352 AND
wp_posts.post_parent = 20 AND wp_posts.post_type = 'revision' AND
((wp_posts.post_status = 'inherit')) ORDER BY wp_posts.post_date DESC`
--> Returns incorrect (oldest) revision (ID = 352)
So when I click Preview Changes in Page, I always see the wrong revision
despite there are multiple revisions created.
I think the issue we have is the param `name` in `WP_Query` from
`wp_get_post_autosave` didn't work properly for all the cases we have.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63446>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list