WordPress.org

Make WordPress Core

Changeset 39333


Ignore:
Timestamp:
11/21/2016 07:15:05 PM (18 months ago)
Author:
westonruter
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/customize-preview-nav-menus.js

    r38991 r39333  
    2424            } );
    2525            api.bind( 'add', function( setting ) {
    26                 self.bindSettingListener( setting, { fire: true } );
     26
     27                /*
     28                 * Handle case where an invalid nav menu item (one for which its associated object has been deleted)
     29                 * is synced from the controls into the preview. Since invalid nav menu items are filtered out from
     30                 * being exported to the frontend by the _is_valid_nav_menu_item filter in wp_get_nav_menu_items(),
     31                 * the customizer controls will have a nav_menu_item setting where the preview will have none, and
     32                 * this can trigger an infinite fallback refresh when the nav menu item lacks any valid items.
     33                 */
     34                if ( setting.get() && ! setting.get()._invalid ) {
     35                    self.bindSettingListener( setting, { fire: true } );
     36                }
    2737            } );
    2838            api.bind( 'remove', function( setting ) {
Note: See TracChangeset for help on using the changeset viewer.