Opened 42 hours ago
Last modified 17 hours ago
#63446 new defect (bug)
Preview Changes show wrong revisions
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 6.8 |
Component: | Autosave | Keywords: | 2nd-opinion |
Focuses: | Cc: |
Description
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.
Reproduction Report
Description
This report validates whether the issue can be reproduced.
Environment
Actual Results
Supplemental Artifacts
See Below Screencast for the reference.
https://www.awesomescreenshot.com/video/39851233?key=5f3deac34cf921876ea47e9dc7e94333