[wp-trac] [WordPress Trac] #47133: Post's global variables not available on content_pagination filter
WordPress Trac
noreply at wordpress.org
Mon May 6 14:39:33 UTC 2019
#47133: Post's global variables not available on content_pagination filter
-------------------------------+---------------------
Reporter: david.binda | Owner: (none)
Type: defect (bug) | Status: new
Priority: high | Milestone: 5.2
Component: Posts, Post Types | Version: trunk
Severity: normal | Resolution:
Keywords: 2nd-opinion | Focuses:
-------------------------------+---------------------
Changes (by boonebgorges):
* keywords: => 2nd-opinion
Comment:
Thanks, @davidbinda.
I don't see an obvious fix for this. If we moved the 'content_pagination'
filter into `WP_Query::setup_postdata()` (as with `'the_post'` in
[45285]), then the values of `$numpages`, `$more`, and `$multipage` that
are set in `generate_postdata()`
https://github.com/WordPress/WordPress/blob/e464f03549f0142a82a636beb2f4f9f4793ba760
/wp-includes/class-wp-query.php#L4301 would be generated *before* the
filter is applied. So you could end up with a `$pages` global that doesn't
match what was used to create these other globals.
Based on the late date and the following facts, I'd like to suggest that
we do not make any further changes, and accept this minor compatibility
break:
1. The fact that this appears to be an extreme edge case
2. The fact that it will be hard to come up with a fix that doesn't
violate the spirit of [44941] (namely, by hoisting values into the global
scope inside of the `generate_postmeta()` method)
3. The fact that the `'content_pagination'` filter receives the `$post`
variable as a parameter, which is, for reasons aside from this ticket, the
more reliable way to determine the post context during
`'content_pagination'` callbacks (and, as such, is a "fix" or at least a
workaround for anything that may break)
If it helps to mitigate, I (maybe with the assistance of @davidbinda ?)
could write a dev-note.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/47133#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list