[wp-trac] [WordPress Trac] #56689: Use WP_Query in get_page_by_path
WordPress Trac
noreply at wordpress.org
Thu Feb 2 13:11:46 UTC 2023
#56689: Use WP_Query in get_page_by_path
-------------------------------------------------+-------------------------
Reporter: spacedmonkey | Owner:
| spacedmonkey
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: 6.2
Component: Query | Version: trunk
Severity: normal | Resolution:
Keywords: needs-testing has-patch has-unit- | Focuses:
tests has-testing-info | performance
-------------------------------------------------+-------------------------
Comment (by spacedmonkey):
Replying to [comment:10 iandunn]:
> There's code in the wild that calls `get_page_by_path()` in
`pre_get_posts` callbacks. In that scenario it looks like this causes an
infinite loop fatal error.
>
> For example, [https://github.com/WordPress/wporg-
developer/blob/2a230399c48bd4cd989c7ac5b68c3767ed250ab1/source/wp-
content/themes/wporg-developer-2023/inc/handbooks.php#L109
handbooks.php:109] and
[https://github.com/WordPress/wordpress.org/blob/94807f3fad26c2cf009bfd747d4d49b68139468c/wordpress.org/public_html
/wp-content/plugins/handbook/inc/template-tags.php#L132 template-
tags.php:132] on w.org.
>
> xref https://wordpress.slack.com/archives/C02QB8GMM/p1675204296499039
>
> Is there something Core should do to handle that situation gracefully?
This comment is a little unclear. What is the worry here? Why do we need
to revert?
It worth noting that there is already a nested WP_Query in WP_Query. See
this [https://github.com/WordPress/wordpress-
develop/blob/0c97bbc1189800763203f20ed612339472150121/src/wp-includes
/class-wp-query.php#L3430-L3449 example].
`pre_get_posts` is a really powerful hook, if it is missed it can generate
errors. Looks like a brital implementation.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56689#comment:12>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list