[wp-trac] [WordPress Trac] #56926: Infinite loop in wp_nav_menu

WordPress Trac noreply at wordpress.org
Fri Oct 28 10:00:06 UTC 2022


#56926: Infinite loop in wp_nav_menu
--------------------------+-----------------------------
 Reporter:  david.binda   |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Menus         |    Version:  6.1
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Testing the r54478 on WordPress.com, I have noticed an infinite loop on
 some sites.

 On certain sites, there are nav_menu_items which have the
 `_menu_item_menu_item_parent` meta set to their own ID. Eg.: nav_menu_item
 with ID `281` has the `_menu_item_menu_item_parent` meta value set to
 `281`, which breaks the `while` loop in
 https://core.trac.wordpress.org/browser/trunk/src/wp-includes/nav-menu-
 template.php?rev=54478#L211 as the `$menu_item_parent` variable is getting
 set to the same, `281` value over and over.

 The ultimate root cause for the infinite loop is the data corruption (of
 some kind), which happened at some point in the past on the sites where
 the infinite loop happens.

 While I haven't been able to figure out how the value of the
 `_menu_item_menu_item_parent` had been set to the same value as is it's
 parent nav_menu_item ID, perhaps it would still be beneficial adding a
 safe guard to the newly introduced logic agains the infinite loop, since
 it's been observed on multiple sites?

 I was thinking something like:

 {{{#!php
 <?php
 while ( $menu_item_parent && $menu_item_parent != $menu_item_key ) {
 }}}

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


More information about the wp-trac mailing list