[wp-trac] [WordPress Trac] #55917: Fatal error in WP6.0 when calling get_current_screen on the pre_get_posts action

WordPress Trac noreply at wordpress.org
Sat Jun 25 22:16:18 UTC 2022


#55917: Fatal error in WP6.0 when calling get_current_screen on the pre_get_posts
action
----------------------------+-----------------------------
 Reporter:  lumpysimon      |       Owner:  (none)
     Type:  defect (bug)    |      Status:  new
 Priority:  normal          |   Milestone:  6.0.1
Component:  Administration  |     Version:  6.0
 Severity:  normal          |  Resolution:
 Keywords:  needs-testing   |     Focuses:  administration
----------------------------+-----------------------------

Comment (by azouamauriac):

 In addition of the snippet in this ticket description, we can add the
 following(in function.php) to reproduce the issue
 {{{

 add_action( 'wp_loaded', 'test' );
 function test(){
         var_dump(wp_get_recent_posts());
 }
 }}}
 Therefore the bug is occurring because the hook  `wp_loaded` triggers
 `pre_get_posts` earlier, before `get_current_screen()` is available... I'm
 wondering if we can change `wp_loaded` by another without breaking
 anything.

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


More information about the wp-trac mailing list