Make WordPress Core

Opened 42 hours ago

Last modified 17 hours ago

#63446 new defect (bug)

Preview Changes show wrong revisions

Reported by: daomapsieucap's profile daomapsieucap 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.

Change History (2)

This ticket was mentioned in Slack in #core-test by oglekler. View the logs.


33 hours ago

#2 @pmbaldha
17 hours ago

  • Keywords 2nd-opinion added

Reproduction Report

Description

This report validates whether the issue can be reproduced.

Environment

  • WordPress: 6.8.1
  • PHP: 8.2.27
  • Server: nginx/1.26.1
  • Database: mysqli (Server: 8.0.35 / Client: mysqlnd 8.2.27)
  • Browser: Chrome 136.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Twenty-Five 1.2
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.0

Actual Results

  1. ❌ Can't reproduced.

Supplemental Artifacts

See Below Screencast for the reference.

https://www.awesomescreenshot.com/video/39851233?key=5f3deac34cf921876ea47e9dc7e94333

Last edited 17 hours ago by pmbaldha (previous) (diff)
Note: See TracTickets for help on using tickets.
OSZAR »