Unable to create new menu link

Created on 17 November 2023, 8 months ago

Problem/Motivation

I recently prepared my site to migrate it to the staging environment. Shortly afterwords, I have been unable to create new menu items due to a lengthy error that pops up:

Drupal\Core\Entity\EntityStorageException: SQLSTATE[HY000]: General error: 1364 Field 'parent' doesn't have a default value: INSERT INTO "menu_tree" ("id", "menu_name") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1); Array ( [:db_insert_placeholder_0] => menu_link_content:83480782-adf3-4c99-82fa-e91ba2885eb5 [:db_insert_placeholder_1] => main ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 817 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Steps to reproduce

1. Go to Menus, then Main Navigation
2. Create a new link
3. Title (Test), Link (), Description (Test Link)
4. Click Save
5. Experience bug

Of course, without knowing what I did to cause this issue, these reproductions steps are incomplete.

Possible causes

I am not sure what is the cause of this error, or how to reproduce it in other sites.

The only thing I can think of is that I had experienced a collation error when trying to import the SQL dump into my staging database. This happened despite me setting my database to use collation utf8mb4_unicode_ci during creation, which for some reason only set the database to use this collation and not the tables or columns. I had to create alter queries to modify the collation of the database, tables and columns to be utf8mb4_unicode_ci.

Similar Issues

There was a similar issue posted here πŸ’¬ Field revision_id does not have a default value Fixed , but this was closed due to inactivity. There was a fix proposed for individuals, but I am hesitant to try this because at least one commenter said that the fix is not correct and that this is a bug within core.

Drush Watchdog Output

I found another similar issue where the user mentioned a Drush watchdog command. I ran this myself and found that I have a number of errors across multiple tables:

drush watchdog-show
 ------ -------------- ------------------- ---------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
  ID     Date           Type                Severity   Message                                                                                                                                                                                       
 ------ -------------- ------------------- ---------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
  1593   17/Nov 10:45   php                 Error      Drupal\Core\Entity\EntityStorageException: SQLSTATE[HY000]: General error: 1364 Field 'parent' doesn't have a default value: INSERT INTO "menu_tree" ("id", "menu_name") VALUES (:db_insert_  
  1592   17/Nov 10:45   menu_link_content   Error      Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[HY000]: General error: 1364 Field 'parent' doesn't have a default value: INSERT INTO "menu_tree" ("id", "menu_name") VA  
  1591   17/Nov 10:41   php                 Error      Drupal\Core\Entity\EntityStorageException: SQLSTATE[HY000]: General error: 1364 Field 'parent' doesn't have a default value: INSERT INTO "menu_tree" ("id", "menu_name") VALUES (:db_insert_  
  1590   17/Nov 10:41   menu_link_content   Error      Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[HY000]: General error: 1364 Field 'parent' doesn't have a default value: INSERT INTO "menu_tree" ("id", "menu_name") VA  
  1589   17/Nov 10:40   menu                Error      Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[HY000]: General error: 1364 Field 'parent' doesn't have a default value: INSERT INTO "menu_tree" ("id", "menu_name") VA  
  1588   17/Nov 10:40   views               Info       The view Statistics has been deleted.                                                                                                                                                         
  1587   16/Nov 16:53   php                 Error      Symfony\Component\HttpKernel\Exception\HttpException: The specified #ajax callback is empty or not callable. in Drupal\Core\Form\FormAjaxResponseBuilder->buildResponse() (line 67 of /Users  
  1586   16/Nov 16:53   menu                Error      Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[HY000]: General error: 1364 Field 'parent' doesn't have a default value: INSERT INTO "menu_tree" ("id", "menu_name") VA  
  1585   16/Nov 16:40   menu                Error      Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[HY000]: General error: 1364 Field 'parent' doesn't have a default value: INSERT INTO "menu_tree" ("id", "menu_name") VA  
  1584   16/Nov 16:40   system              Info       charts_billboard module installed.                                                                                                                                                            
 ------ -------------- ------------------- ---------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 

Complete Error

The website encountered an unexpected error. Please try again later.

Drupal\Core\Entity\EntityStorageException: SQLSTATE[HY000]: General error: 1364 Field 'parent' doesn't have a default value: INSERT INTO "menu_tree" ("id", "menu_name") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1); Array ( [:db_insert_placeholder_0] => menu_link_content:83480782-adf3-4c99-82fa-e91ba2885eb5 [:db_insert_placeholder_1] => main ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 817 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
Drupal\Core\Database\StatementWrapperIterator->execute(Array, Array) (Line: 44)
Drupal\mysql\Driver\Database\mysql\Insert->execute() (Line: 295)
Drupal\Core\Menu\MenuTreeStorage->doSave(Array) (Line: 231)
Drupal\Core\Menu\MenuTreeStorage->save(Array) (Line: 317)
Drupal\Core\Menu\MenuLinkManager->addDefinition('menu_link_content:83480782-adf3-4c99-82fa-e91ba2885eb5', Array) (Line: 238)
Drupal\menu_link_content\Entity\MenuLinkContent->postSave(Object, ) (Line: 563)
Drupal\Core\Entity\EntityStorageBase->doPostSave(Object, ) (Line: 781)
Drupal\Core\Entity\ContentEntityStorageBase->doPostSave(Object, ) (Line: 489)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 806)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 339)
Drupal\Core\Entity\EntityBase->save() (Line: 130)
Drupal\menu_link_content\Form\MenuLinkContentForm->save(Array, Object)
call_user_func_array(Array, Array) (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 597)
Drupal\Core\Form\FormBuilder->processForm('menu_link_content_menu_link_content_form', Array, Object) (Line: 325)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 48)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object) (Line: 28)
Drupal\menu_link_content\Controller\MenuController->addLink(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
πŸ› Bug report
Status

Active

Version

10.1 ✨

Component
Menu systemΒ  β†’

Last updated about 11 hours ago

Created by

πŸ‡¨πŸ‡¦Canada ciesinsg

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024