WordPress.org

Make WordPress Core

Opened 5 months ago

Closed 5 months 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:

Description

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:
https://wordpress.org/support/topic/customizer-preview-keeps-refreshing-infinitely-under-certain-circumstances/#post-8463765
https://wordpress.slack.com/archives/core-customize/p1479733895000901

Attachments (1)

38890.0.diff (1.2 KB) - added by westonruter 5 months ago.

Download all attachments as: .zip

Change History (6)

#1 @westonruter
5 months ago

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

@westonruter
5 months ago

#2 @westonruter
5 months ago

  • Keywords has-patch added; needs-patch removed

#3 @swissspidy
5 months ago

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

#4 @westonruter
5 months 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
5 months 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.