[wp-trac] [WordPress Trac] #50019: remove_meta_box triggers warning in PHP 7.4
WordPress Trac
noreply at wordpress.org
Mon Apr 27 19:27:06 UTC 2020
#50019: remove_meta_box triggers warning in PHP 7.4
-------------------------------+-----------------------------
Reporter: coolmann | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Posts, Post Types | Version: 5.4
Severity: major | Keywords: needs-patch
Focuses: ui |
-------------------------------+-----------------------------
After updating my local sandbox to PHP 7.4, I started seeing errors on my
Edit Page screen for my custom post type:
Notice: Trying to access array offset on value of type bool in /[..]/wp-
admin/includes/template.php on line 1079, 1080, 1081
After some research, I narrowed down the issue to a call in one of my
plugin, which removes one of the metaboxes on that screen:
remove_meta_box( 'profile_rolediv', 'people', 'normal' );
Everything had been working fine in earlier versions. Looking at the code
in template.php, it looks like remove_meta_box just sets values to false,
instead of removing the entry:
function remove_meta_box( $id, $screen, $context ) {
.
.
$wp_meta_boxes[ $page ][ $context ][ $priority ][ $id ] = false;
.
.
}
which then causes this line in template.php to fail:
$title = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id
]['title'];
Changing line 1078 in wp-admin/includes/template.php fixes the issue:
} elseif ( 'sorted' == $priority && is_array( $wp_meta_boxes[ $page ][
$a_context ][ $a_priority ][ $id ] ) ) {
Thank you,
Jason
--
Ticket URL: <https://core.trac.wordpress.org/ticket/50019>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list