[wp-trac] [WordPress Trac] #46338: taxonomy_meta_box_sanitize_cb_checkboxes: Warning: array_map(): Expected parameter 2 to be an array, string given

WordPress Trac noreply at wordpress.org
Mon Apr 15 13:09:57 UTC 2024


#46338: taxonomy_meta_box_sanitize_cb_checkboxes: Warning: array_map(): Expected
parameter 2 to be an array, string given
--------------------------+------------------------------
 Reporter:  conner_bw     |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Taxonomy      |     Version:  5.1
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by oglekler):

 `/wp-admin/includes/post.php:438`

 PHP 8.0.30, WordPress 6.5 (6.5.2 - the same).

 {{{
         // Convert taxonomy input to term IDs, to avoid ambiguity.
         if ( isset( $post_data['tax_input'] ) ) {
                 foreach ( (array) $post_data['tax_input'] as $taxonomy =>
 $terms ) {
                         $tax_object = get_taxonomy( $taxonomy );

                         if ( $tax_object && isset(
 $tax_object->meta_box_sanitize_cb ) ) {
                                 $translated['tax_input'][ $taxonomy ] =
 call_user_func_array( $tax_object->meta_box_sanitize_cb, array( $taxonomy,
 $terms ) );
                         }
                 }
         }
 }}}

 During Post edit $terms is an array:

 {{{
 Array
 (
     [0] => 0
     [1] => 21
     [2] => 22
 )
 }}}

 During Quick edit, it is a string:
 {{{
  test, test2,
 }}}

 And with PHP 8+ I am getting `PHP Fatal error:  Uncaught TypeError:
 array_map(): Argument #2 ($array) must be of type array, string given in
 ...\wp-admin\includes\post.php:2233`

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


More information about the wp-trac mailing list