[wp-trac] [WordPress Trac] #28138: Updating menu item requires passing all of a menu item's data to wp_update_nav_menu_item()

WordPress Trac noreply at wordpress.org
Wed Jul 8 03:48:12 UTC 2015


#28138: Updating menu item requires passing all of a menu item's data to
wp_update_nav_menu_item()
---------------------------------+------------------
 Reporter:  danielbachhuber      |       Owner:
     Type:  defect (bug)         |      Status:  new
 Priority:  normal               |   Milestone:  4.3
Component:  Menus                |     Version:  3.0
 Severity:  normal               |  Resolution:
 Keywords:  has-patch has-tests  |     Focuses:
---------------------------------+------------------
Changes (by ericmann):

 * keywords:  needs-unit-tests has-patch => has-patch has-tests


Comment:

 Updated the patch and added some unit tests. I noticed, while writing the
 tests, a minor bug in the conditional. Since we're calling
 `wp_setup_nav_menu_item()` to populate the nav item, the class list is
 auto-converted into an array. This causes the later invocation of
 `explode()` to, well, explode when an existing item is updated. I've
 modified the patch slightly to re-convert the class list into a string
 upon retrieval so `explode()` behaves properly.

 Alternatively, we could just run an `is_array()` check before sanitizing
 the class elements. Both patterns work, and I don't really think it
 matters. However, for the sake of clarity, I'm attaching a ''second''
 patch with an array check in a moment. Feel free to go with either one
 (the tests are the same and pass regardless).

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


More information about the wp-trac mailing list