Make WordPress Core

Opened 3 months ago

Last modified 3 months ago

#43625 new defect (bug)

When there are invalid items in a menu, the customizer enters an infinite loop of refreshing when trying to render wp_nav_menu.

Reported by: flamboyantpretender Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.9.5
Component: Customize Keywords:
Focuses: javascript, administration Cc:


I had an issue where I echoed certain things on the homepage.

Strangely enough, removing that part of code fixed it, but adding something that would 'echo' things out broke it again.

Long story short, I decoupled every single thing in my theme and discovered that when you call wp_nav_menu, like so:

                            wp_nav_menu( array(
                                'theme_location'=> 'menu-1',
                                'menu_id'       => 'primary-menu',
                                'menu_class'    => 'menu szWeo1-unique-menu',
                                'container'        => 'false'
                            ) );

but there are invalid items (removed pages or so, I believe) within that menu, the Customizer enters an infinite refresh loop and it tries to re-render that menu, but gets stuck, aborts and repeats.

Replication should be easy, simply create an item in the menu that corresponds to a page, then delete that page. This should render the item within the menu "invalid". I can't exactly say that this will work, but please do contribute if you know a way of rendering these items invalid in a consistent way.

Change History (1)

#1 @flamboyantpretender
3 months ago

Update: Can confirm, adding a page link to the menu and then later on removing that page renders a menu item "invalid".

Update2: It seems the error is actually triggered by calling another outer file that echoes something, but the error gets fixed by removing the invalid menu item.

I created a new file:


function echo_hey() {
    echo 'hey';


Linked it up within my functions.php, as such:

require_once( get_template_directory_uri() . '/inc/echo_hello.php');

Then, within my header.php (or really anywhere), I called it:


This printed the 'hey' but sent the Customizer into the refresh loop and generated this error at times:

( ! ) Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\wordpress\wp-content\themes\s-master\includes\Sprout\Contact\ContactBlock.php:16) in C:\xampp\htdocs\wordpress\wp-admin\includes\misc.php on line 1114

Keep in mind that this is with output_buffering set to Off in the php.ini file, but if we allow a buffer of, say, 4096, this error dissapears, but the refresh bug still happens if we have an invalid menu item - but gets fixed if we remove the invalid menu item, as I've stated before.

Last edited 3 months ago by flamboyantpretender (previous) (diff)
Note: See TracTickets for help on using tickets.