[wp-trac] [WordPress Trac] #57169: Prevent saving of invalid menu_item_parent

WordPress Trac noreply at wordpress.org
Wed Jan 4 14:14:07 UTC 2023


#57169: Prevent saving of invalid menu_item_parent
-----------------------------------+-----------------------
 Reporter:  azaozz                 |       Owner:  azaozz
     Type:  defect (bug)           |      Status:  reopened
 Priority:  normal                 |   Milestone:  6.1.2
Component:  Menus                  |     Version:  6.1
 Severity:  normal                 |  Resolution:
 Keywords:  has-patch fixed-major  |     Focuses:
-----------------------------------+-----------------------

Comment (by Chouby):

 @azaozz I'm afraid that [54973] introduces a breaking change, more
 specifically the cast to int of the menu item ids at this
 [https://github.com/WordPress/wordpress-
 develop/commit/9d6a0a351347651cdb686ce3ee3650cc45485155#diff-
 1b173eae0abba649940037e08a3eb19362c5c7fe0a7a570a03aa485eee485938R203
 line].

 This is probably not an issue for WordPress itself but will break with
 some plugins. It's at least the case in Polylang. Indeed, in this plugin,
 we are dynamically creating menu items with non-numeric ids. I would not
 be surprised that other multilingual plugins like WPML do the same.

 For the language switcher, there is a unique menu item in database (and a
 unique menu item displayed in the backend). However, this menu item is
 splitted on frontend to get one menu item per language. Of course, we had
 to set a unique ID for the dynamic menu items and so we append the
 language code to the db menu item id resulting in non numeric menu item
 IDs. If you are interested in the Polylang code: See
 https://github.com/polylang/polylang/blob/3.3/frontend/frontend-nav-
 menu.php#L134

 Would it be possible to avoid the cast to int the test?

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


More information about the wp-trac mailing list