[wp-trac] [WordPress Trac] #53824: Fatal error when in action pre_get_posts call *_template()

WordPress Trac noreply at wordpress.org
Thu Jul 29 12:43:52 UTC 2021


#53824: Fatal error when in action pre_get_posts call *_template()
--------------------------+-----------------------------
 Reporter:  Adiasz        |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  5.8
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 code:

 {{{

 add_action('pre_get_posts', function($query) {
     // when is on page
     get_page_template();
 });

 }}}

 breaks WP core in
 "Allowed memory size of 134217728 bytes exhausted" in wp-includes\class-
 wp-query.php

 steps:
 1. Add upper action to functions.php
 2. Enter to any WP page
 3. Fatal ERROR

 It breaks WP in each function:
 get_single_template()
 get_category_template()
 get_post_type_archive_template()
 get_taxonomy_template()
 get_archive_template()
 get_home_template()

 when function is fired in 'pre_get_posts' hook and this is current WP
 page.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/53824>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list