[wp-trac] [WordPress Trac] #46482: Non-hierarchical taxonomies using checkbox display are not saving in quick edit

WordPress Trac noreply at wordpress.org
Thu Mar 16 13:00:17 UTC 2023


#46482: Non-hierarchical taxonomies using checkbox display are not saving in quick
edit
----------------------------+------------------------------
 Reporter:  mooberrydreams  |       Owner:  (none)
     Type:  defect (bug)    |      Status:  new
 Priority:  normal          |   Milestone:  Awaiting Review
Component:  Taxonomy        |     Version:  5.1
 Severity:  normal          |  Resolution:
 Keywords:                  |     Focuses:
----------------------------+------------------------------

Comment (by mdifelice):

 Even if the `meta_box_sanitize_cb` argument is not set, WordPress will
 still [https://core.trac.wordpress.org/browser/tags/6.1.1/src/wp-includes
 /class-wp-taxonomy.php#L455 use]
 `taxonomy_meta_box_sanitize_cb_checkboxes` as the sanitizer when the
 `meta_box_cb` is set to `post_categories_meta_box`.

 When using quick edit, WordPress
 [https://core.trac.wordpress.org/browser/tags/6.1.1/src/wp-admin/includes
 /class-wp-posts-list-table.php#L1778 does not] take into account those
 arguments when printing the term selector, it just checks if the taxonomy
 is hierarchical or not. However, when saving the quick edit data, it
 [https://core.trac.wordpress.org/browser/tags/6.1.1/src/wp-
 admin/includes/post.php#L416 uses] what the `meta_box_sanitize_cb`
 defines. That is a strong inconsistency: quick edit sends a string, and
 the save function attempts to sanitize an array. The result is a fatal
 error (''Uncaught Error: array_map(): Argument 2 ($array) must be of type
 array, string given in /wp-admin/includes/post.php on line 2107'').

 It is hard to propose a solution here. A quick fix I found for my plugins
 is to add the `show_in_quick_edit` argument with a `false` value on these
 cases, which prevents the error but it is far from being a desirable
 solution.

 I think that the best approach would be to use the same functions used in
 the edit screen in the quick edit screen, but without rewriting them it
 may break some retro-compatibility.

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


More information about the wp-trac mailing list