[wp-trac] [WordPress Trac] #46671: wp-admin/revisions.php uses the $post global in the wrong way

WordPress Trac noreply at wordpress.org
Wed Jul 10 23:17:59 UTC 2019


#46671: wp-admin/revisions.php uses the $post global in the wrong way
--------------------------+-----------------------------
 Reporter:  tofandel      |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Future Release
Component:  Revisions     |     Version:  5.2
 Severity:  major         |  Resolution:
 Keywords:  needs-patch   |     Focuses:  administration
--------------------------+-----------------------------

Comment (by archon810):

 I just spent hours trying to figure out why restoring revisions sometimes
 redirects to the wrong post and after debugging and pulling my hair out
 arrived at a conclusion that this has to be a bug in WP core.

 Then I found this ticket (along with
 https://core.trac.wordpress.org/ticket/18408 which is still unresolved
 after 8 years and may or may not be related).

 In 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()`.

 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.

 Is there anyone who can take a look at properly resolving this bug
 @SergeyBiryukov?

 Thanks.

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


More information about the wp-trac mailing list