Usage of get_current_screen() without checking its availability leaading to potential fatal error #2515
Labels
[Priority] Low
This issue/pull request is not immediate
[Type] Bug
Something that is not working as expected
Milestone
Describe the bug:
Possible fatal error, due to function
get_current_screen()
not always being defined here: https://github.com/godaddy-wordpress/coblocks/blob/master/includes/block-migrate/loader.php#L30The problem is, that the code automatically assumes that the function is defined, which is not always the case. Only if
screen.php
oradmin.php
is loaded, it will be defined.Since the code gets executed on
the_post
action, it can happen during any 3rd party plugin request that loops through posts usingthe_post()
.To reproduce:
Create a custom query from a plugin that uses
the_post()
that runs withoutscreen.php
oradmin.php
being loaded.Expected behavior:
get_current_screen()
is actually defined.screen.php
oradmin.php
are included:require_once ABSPATH . 'wp-admin/includes/screen.php';
require_once ABSPATH . 'wp-admin/admin.php';
is_block_editor
without check.Isolating the problem:
WordPress version:
6.1.1+
The text was updated successfully, but these errors were encountered: