[wp-trac] [WordPress Trac] #49109: Array offset access notice problem with `remove_meta_box()` and `add_meta_box()` function.

WordPress Trac noreply at wordpress.org
Tue Dec 31 13:57:29 UTC 2019


#49109: Array offset access notice problem with `remove_meta_box()` and
`add_meta_box()` function.
-------------------------------+-----------------------------
 Reporter:  kmvan              |      Owner:  (none)
     Type:  defect (bug)       |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Posts, Post Types  |    Version:  5.3.2
 Severity:  critical           |   Keywords:
  Focuses:                     |
-------------------------------+-----------------------------
 When I use `remove_meta_box()` function:
 {{{#!php
 <?php
 \remove_meta_box('postcustom', 'post', 'normal');
 }}}

 The function will set `postcustom` to false, code in /wp-
 admin/includes/template.php line 1405:
 {{{#!php
 <?php
 $wp_meta_boxes[ $page ][ $context ][ $priority ][ $id ] = false;
 }}}

 Shall use `unset`, likes:
 {{{#!php
 <?php
 unset($wp_meta_boxes[ $page ][ $context ][ $priority ][ $id ]);
 }}}


 So, code in /wp-admin/includes/template.php line 1049~1051:
 {{{#!php
 <?php
 if ( ! isset( $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]
 ) ) {
         continue;
 }
 }}}

 The `false` value will be not enter the condition. Likes:
 {{{#!php
 <?php
 $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.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/49109>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list