[wp-trac] [WordPress Trac] #47114: global $pages not available on the_post action

WordPress Trac noreply at wordpress.org
Sat May 4 01:11:40 UTC 2019


#47114: global $pages not available on the_post action
-------------------------------+---------------------
 Reporter:  david.binda        |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  highest omg bbq    |   Milestone:  5.2
Component:  Posts, Post Types  |     Version:  trunk
 Severity:  normal             |  Resolution:
 Keywords:                     |     Focuses:
-------------------------------+---------------------
Changes (by azaozz):

 * priority:  normal => highest omg bbq
 * milestone:  Awaiting Review => 5.2


Comment:

 This looks like a regression that may affect a lot of themes and plugins.
 The `the_post` action was explicitly fired (inside the loop) after
 `setup_postdata()` has set the globals. Even looking at the inline docs
 suggests that:

 {{{
 * Set up global post data. (from setup_postdata())
 ...
 * Fires once the post data has been setup. (from do_action_ref_array(
 'the_post', ... ))
 }}}

 Firing it before the globals are set would also affect `reset_postdata()`
 as some of the globals will be from the "other" $post, before they are
 overwritten with the "current" post's data.

 I don't see problems with moving the action back to `setup_postdata()` so
 it fires after the expected globals are set as in 47114.diff. This doesn't
 seem to affect the fix from #42814 [44941], but may be missing something.
 @boonebgorges @spacedmonkey could you have a look?

 Moving this for consideration before 5.2 and setting it as high priority
 as we are just few days from release.

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


More information about the wp-trac mailing list