Unusable menus and “Illegal widget setting ID: nav_menu_item” error

This is a bug in my WP install that has crept up unknowingly; I can’t say for sure when it began.

To describe it: there were menus created in the Appearance -> Menus page early in the site’s history, and they work perfectly, as in:

  • They have menu items
  • They can be assigned to menu locations
  • They can be renamed

As of recently, as new menus need to be created, I’ve noticed the following problems when creating a new menu:

New menus can be created, but after clicking “Create Menu”, the sidebar with Posts and Pages to use as menu items, is still grayed out
The menu cannot be renamed:

  1. The menu name does not show up in the “Menu Name” text field, and subsequent clicks to “Create Menu” simply duplicates these new-yet-unusable menus each again per new click (ex: I create Test1, then create Test2.. now there are 2 Test1 entries, and 2 Test2 entries… creating Test3 repeats the effect, creating 3 of each)
  2. Clicking “Manage in Customizer” next to the “Menus” heading results in the following error:
    Fatal error: Uncaught exception 'Exception' with message 'Illegal widget setting ID: nav_menu_item[]' in /Applications/MAMP/htdocs/discoverlongisland/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php:179 
    Stack trace: #0 /Applications/MAMP/htdocs/discoverlongisland/wp-includes/class-wp-customize-nav-menus.php(551): WP_Customize_Nav_Menu_Item_Setting->__construct(Object(WP_Customize_Manager), 'nav_menu_item[]', Array) 
    #1 [internal function]: WP_Customize_Nav_Menus->customize_register(Object(WP_Customize_Manager)) 
    #2 /Applications/MAMP/htdocs/discoverlongisland/wp-includes/plugin.php(525): call_user_func_array(Array, Array) 
    #3 /Applications/MAMP/htdocs/discoverlongisland/wp-includes/class-wp-customize-manager.php(583): do_action('customize_regis...', Object(WP_Customize_Manager)) 
    #4 [internal function]: WP_Customize_Manager->wp_loaded('') 
    #5 /Applications/MAMP/htdocs/discoverlongisland/wp-includes/plugin.php(525): call_user_func_array(Array, Array) 
    #6 /Applications/MAMP/htdocs/discoverlongisland/wp-settings. in /Applications/MAMP/htdocs/discoverlongisland/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php on line 179

I’ve disabled all plugins and the problem persists.

Has anyone run into this before?

Solutions Collecting From Web of "Unusable menus and “Illegal widget setting ID: nav_menu_item” error"

I had the same problem. I did not have pre-existing menus, but newly created ones had the same symptoms as you described.

In my case, the problem was a ill-defined table wp_terms. It was missing the AUTO_INCREMENT flag on the column term_id as well as all indexes and the primary key.

I can only assume that the update process messed up at some point in the past. I run a pretty ancient installation which was originally set up in 2005.

The following change fixed the problem for me:

ALTER TABLE `wp_terms`
ADD PRIMARY KEY (`term_id`),
ADD INDEX `name` (`name`),
ADD INDEX `slug` (`slug`);

I would recommend comparing your schema against a current schema though. wp_term_taxonomy might be involved as well (wasn’t in my case).