[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
Thu Aug 4 12:28:22 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.1
Component:  Query                    |     Version:  6.0
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:
-------------------------------------+---------------------

Comment (by hellofromTonya):

 I'm so sorry I'm late in responding to this issue. Somehow I missed the
 pings. My apologies.

 [comment:12 From @SergeyBiryukov]:
 >I was told by @aristath that @hellofromTonya is working on a refactoring
 of core's Webfonts API implementation, and this patch may not be needed in
 near future.

 The WP 6.0 [53282] stopgap is temporary and will be replaced in the future
 when a proper API is introduced (currently planned for WP 6.1).

 [comment:4 As noted by] @mukesh27:
 >I try to track the issue and this function call `$settings =
 WP_Theme_JSON_Resolver::get_merged_data()->get_settings();` generate issue
 for 6.0 version and function dependency called `wp_get_recent_posts()`
 function to get recent posts for `wp_global_styles` post type.

 While this specific fatal is pointing at the stopgap being hooked into
 `wp_loaded`, is that the true root cause? Or is the root cause deeper
 within the code, meaning a hidden problem exists that could cause other
 problems in other scenarios?

 Thinking out loud, I wonder:

 * Is there are other instances within Core where this same code might also
 be called before `get_current_screen()` is available?
 * What is the impact of not having `get_current_screen()` function in
 memory when this happens? (ie beyond the fatal noted in this specific use
 case)

 The answers may reveal if there is a deeper issue within Core, if there
 are some scenarios where theme.json resolver may not work as intended,
 and/or if our assumptions (such as when to fetch the user's selected
 global styles) are incorrect.

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


More information about the wp-trac mailing list