Opened 15 months ago
Last modified 15 months ago
#63446 new defect (bug)
Preview Changes show wrong revisions
| Reported by: | daomapsieucap | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Autosave | Version: | 6.8 |
| Severity: | normal | Keywords: | 2nd-opinion |
| Cc: | Focuses: |
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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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