[wp-trac] [WordPress Trac] #18408: Can't wp_reset_postdata after custom WP_Query in an admin edit page

WordPress Trac noreply at wordpress.org
Fri May 30 02:15:17 UTC 2025


#18408: Can't wp_reset_postdata after custom WP_Query in an admin edit page
-------------------------------------------------+-------------------------
 Reporter:  ericlewis                            |       Owner:  audrasjb
     Type:  defect (bug)                         |      Status:  assigned
 Priority:  normal                               |   Milestone:  Future
                                                 |  Release
Component:  Query                                |     Version:  4.7.2
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch early needs-unit-tests     |     Focuses:
  dev-feedback has-test-info                     |
-------------------------------------------------+-------------------------
Changes (by SirLouen):

 * keywords:  needs-testing has-patch early needs-unit-tests => has-patch
     early needs-unit-tests dev-feedback has-test-info


Comment:

 == Test Report
 === Description
 ✅ This report validates that the indicated patch works as expected.

 Patch tested:
 https://core.trac.wordpress.org/attachment/ticket/18408/18408.6.diff

 === Environment
 - WordPress: 6.9-alpha-60093-src
 - PHP: 8.2.28
 - Server: nginx/1.27.5
 - Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
 - Browser: Chrome 137.0.0.0
 - OS: Windows 10/11
 - Theme: Twenty Twenty-Five 1.2
 - MU Plugins: None activated
 - Plugins:
   * Classic Editor 1.6.7
   * Test Reports 1.2.0

 === Reproduction Steps
 1. Used the plugin
 [https://gist.github.com/billerickson/21ff280fb26c3b98120044d53f4e1b61
 provided here]
 2. Create 2 or 3 pages with titles.
 3. Create 1 post with a title
 4. 🐞 Edit the post, check the Metabox in the sidebar, the title is not
 the post being edited

 === Expected results
 - The title should be one of the post being edited

 === Actual Results
 1.  ✅ Issue resolved with patch.

 === Additional Notes
 1. I've been trying to recreate with some unit test, the scenario in the
 demo plugin, but I've not been able. Maybe I will try tomorrow. The
 problem is that I'm unable to replicate the Admin Edit page, where
 theoretically `/wp-admin/post.php` happens to fail.
 2. I'm not 100% confident of which use-cases
 [https://core.trac.wordpress.org/ticket/18408#comment:50 commented here]
 could be replicated into `unit-tests`. Maybe @Howdy_McGee could dig into
 them. But also, maybe, Unit Tests can be added in a future, given that
 technically, the patch solves the issue correctly.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/18408#comment:52>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list