Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #46671, comment 4


Ignore:
Timestamp:
07/10/2019 11:25:30 PM (7 years ago)
Author:
archon810
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #46671, comment 4

    initial v1  
    55In our case, we have a hook into `transition_post_status`, and in this hook, we perform a secondary query using the correct `new WP_Query()`, `have_posts()`, and `the_post()`, followed by `wp_reset_postdata()`.
    66
    7 The last post in this secondary query gets erroneously set past `wp_reset_postdata()` and then `wp_restore_post_revision()` ends up using it as a redirect, and we get redirected to the wrong post.
     7The last post in this secondary query erroneously sticks around as `$post` after `wp_reset_postdata()`.
     8
     9This happens as part of `wp-includes/post.php`->`wp_restore_post_revision()`->`wp_update_post()`->`wp_insert_post()`->`wp_transition_post_status()`. The redirect ends up using this incorrect $post.
     10
     11Here's the call stack:
     12[[Image(https://i.imgur.com/06mTD0X.png)]]
    813
    914Is there anyone who can take a look at properly resolving this bug @SergeyBiryukov?
    1015
    1116Thanks.
     17