Make WordPress Core

Opened 4 years ago

Last modified 4 years ago

#49109 new defect (bug)

Array offset access notice problem with `remove_meta_box()` and `add_meta_box()` function.

Reported by: kmvan's profile kmvan Owned by:
Milestone: Awaiting Review Priority: normal
Severity: critical Version: 5.3.2
Component: Posts, Post Types Keywords:
Focuses: Cc:


When I use remove_meta_box() function:

\remove_meta_box('postcustom', 'post', 'normal');

The function will set postcustom to false, code in /wp-admin/includes/template.php line 1405:

$wp_meta_boxes[ $page ][ $context ][ $priority ][ $id ] = false;

Shall use unset, likes:

unset($wp_meta_boxes[ $page ][ $context ][ $priority ][ $id ]);

So, code in /wp-admin/includes/template.php line 1049~1051:

if ( ! isset( $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] ) ) {

The false value will be not enter the condition. Likes:

$a = false;
var_dump(isset($a)); // true

So. array offset access notice shows: /wp-admin/includes/template.php on line 1078

Happening on create/edit post page.

Change History (1)

#1 @DrLightman
4 years ago

bump and experiencing this me too.

even if the function is called presumabily correctly at do_meta_boxes action.

Note: See TracTickets for help on using tickets.