[wp-trac] [WordPress Trac] #56689: Use WP_Query in get_page_by_path

WordPress Trac noreply at wordpress.org
Thu Feb 2 20:38:50 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 2nd-opinion             |  performance
-------------------------------------------------+-------------------------

Comment (by spacedmonkey):

 Looking into this issue, it comes from the fact that `pre_get_posts`
 callbacks calls `get_page_by_path`. Now that `get_page_by_path` calls
 `WP_Query`, it calls which calls `pre_get_posts`. This ends up in a
 recursive loop. This feels pretty edge case, but if this does  not get
 reverted, it means this 100% needs a dev note.

 I don't see a way around this issue. This change results in calling
 `WP_Query` in  `get_page_by_path`, has the caching and performance
 benefit, it comes along with the filters and actions of `WP_Query`. We
 either role with that or revert and mark this as a wontfix. :(

 Does any body have else have any thoughts on this one?

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


More information about the wp-trac mailing list