Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#38890 closed defect (bug) (fixed)

Customize: Selective refresh for nav menus can cause infinite reloads when it contains invalid menu items

Reported by: westonruter Owned by: westonruter
Milestone: 4.7 Priority: normal
Severity: normal Version:
Component: Customize Keywords: has-patch
Focuses: Cc:


The way I've reproduced the problem, as suggested by @swissspidy:

  1. Create 5 posts.
  2. Create a new nav menu and assign to a location.
  3. Assign 5 posts to new nav menu.
  4. Trash the 5 posts so that all of the nav menu items become invalid.
  5. Load site in the customizer and notice infinite reloads.

It appears to be a problem with handleUnplacedNavMenuInstances.

Reported at:

Attachments (1)

38890.0.diff (1.2 KB) - added by westonruter 4 years ago.

Download all attachments as: .zip

Change History (6)

#1 @westonruter
4 years ago

  • Owner set to westonruter
  • Status changed from new to accepted

4 years ago

#2 @westonruter
4 years ago

  • Keywords has-patch added; needs-patch removed

#3 @swissspidy
4 years ago

I can confirm that 38890.0.diff resolves the issue I was having. Thank you!

#4 @westonruter
4 years ago

  • Summary changed from Customize: Nav menus can cause infinite reloads in some situations to Customize: Selective refresh for nav menus can cause infinite reloads when it contains invalid menu items

#5 @westonruter
4 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 39333:

Customize: Prevent selective refresh from causing infinite fallback refreshes when nav menu contains invalid items.

Invalid nav menu items are exported as settings in the customize controls since it is_admin(), but any such nav_menu_item settings are excluded from the preview since it's the frontend. Selective refresh for nav menus needs to ignore the syncing of any such nav_menu_item settings that are _invalid since they are never rendered, and when a nav menu only contains invalid items, an infinite fallback refresh can ensue.

Fixes #38890.

Note: See TracTickets for help on using tickets.