Menu item extras fails to update bundle on install and uninstall when menu content items exist and drupal > 8.7.x is used

Created on 6 April 2019, over 5 years ago
Updated 8 August 2023, over 1 year ago

I run into the following error while trying to install the module with some menu items already created on Drupal 8.7.0-beta1

em class="placeholder">Drupal\Core\Entity\EntityStorageException</em>: SQLSTATE[23000]: Integrity constraint violation: 1048 Column &#039;bundle&#039; cannot be null: UPDATE {menu_link_content} SET revision_id=:db_update_placeholder_0, bundle=:db_update_placeholder_1, uuid=:db_update_placeholder_2, langcode=:db_update_placeholder_3
WHERE id = :db_condition_placeholder_0; Array
(
    [:db_update_placeholder_0] =&gt; 2
    [:db_update_placeholder_1] =&gt; 
    [:db_update_placeholder_2] =&gt; a335513a-6781-4cc2-a49e-3df2421481cc
    [:db_update_placeholder_3] =&gt; en
    [:db_condition_placeholder_0] =&gt; 1
)
 in <em class="placeholder">Drupal\Core\Entity\Sql\SqlContentEntityStorage-&gt;save()</em> (line <em class="placeholder">847</em> of <em class="placeholder">core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php</em>). 
Drupal\Core\Database\Statement-&gt;execute(Array, Array) (Line: 631)
Drupal\Core\Database\Connection-&gt;query(&#039;UPDATE {menu_link_content} SET revision_id=:db_update_placeholder_0, bundle=:db_update_placeholder_1, uuid=:db_update_placeholder_2, langcode=:db_update_placeholder_3
WHERE id = :db_condition_placeholder_0&#039;, Array, Array) (Line: 358)
Drupal\Core\Database\Driver\mysql\Connection-&gt;query(&#039;UPDATE {menu_link_content} SET revision_id=:db_update_placeholder_0, bundle=:db_update_placeholder_1, uuid=:db_update_placeholder_2, langcode=:db_update_placeholder_3
WHERE id = :db_condition_placeholder_0&#039;, Array, Array) (Line: 148)
Drupal\Core\Database\Query\Update-&gt;execute() (Line: 946)
Drupal\Core\Entity\Sql\SqlContentEntityStorage-&gt;doSaveFieldItems(Object) (Line: 657)
Drupal\Core\Entity\ContentEntityStorageBase-&gt;doSave(&#039;1&#039;, Object) (Line: 448)
Drupal\Core\Entity\EntityStorageBase-&gt;save(Object) (Line: 838)
Drupal\Core\Entity\Sql\SqlContentEntityStorage-&gt;save(Object) (Line: 394)
Drupal\Core\Entity\EntityBase-&gt;save() (Line: 116)
Drupal\menu_item_extras\Service\MenuLinkContentService-&gt;updateMenuItemsBundle(&#039;footer&#039;) (Line: 21)
menu_item_extras_install()
call_user_func_array(&#039;menu_item_extras_install&#039;, Array) (Line: 392)
Drupal\Core\Extension\ModuleHandler-&gt;invoke(&#039;menu_item_extras&#039;, &#039;install&#039;) (Line: 303)
Drupal\Core\Extension\ModuleInstaller-&gt;install(Array, 1) (Line: 83)
Drupal\Core\ProxyClass\Extension\ModuleInstaller-&gt;install(Array) (Line: 460)
Drupal\system\Form\ModulesListForm-&gt;submitForm(Array, Object)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Form\FormSubmitter-&gt;executeSubmitHandlers(Array, Object) (Line: 51)
Drupal\Core\Form\FormSubmitter-&gt;doSubmitForm(Array, Object) (Line: 590)
Drupal\Core\Form\FormBuilder-&gt;processForm(&#039;system_modules&#039;, Array, Object) (Line: 319)
Drupal\Core\Form\FormBuilder-&gt;buildForm(&#039;system_modules&#039;, Object) (Line: 93)
Drupal\Core\Controller\FormController-&gt;getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer-&gt;executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel-&gt;handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session-&gt;handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle-&gt;handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache-&gt;pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache-&gt;handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware-&gt;handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware-&gt;handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel-&gt;handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel-&gt;handle(Object) (Line: 19)

A similar error happens on uninstall but it is because the schema was not properly installed on hook_install.

This doesn't happen on Drupal 8.6.13.

I investigated a bit and it has to do with the bundle column of the menu_link_content table not being updated to be an entity reference during the install.

I'm going to try to provide some tests and hopefully some kind of solution.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇪🇸Spain rodrigoaguilera Barcelona

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇳India zartab farooquee

    I got this error after saving the menu
    Drupal\Core\Entity\EntityStorageException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'bundle' cannot be null: UPDATE "menu_link_content" SET "revision_id"=:db_update_placeholder_0, "bundle"=:db_update_placeholder_1, "uuid"=:db_update_placeholder_2, "langcode"=:db_update_placeholder_3 WHERE "id" = :db_condition_placeholder_0; Array ( [:db_update_placeholder_0] => 68581 [:db_update_placeholder_1] => [:db_update_placeholder_2] => ba66cf02-b531-4e83-a0e6-4e2a27451afd [:db_update_placeholder_3] => en [:db_condition_placeholder_0] => 68581 ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 815 of core\lib\Drupal\Core\Entity\Sql\SqlContentEntityStorage.php).

  • 🇧🇪Belgium BramDriesen Belgium 🇧🇪

    @zartab farooquee This issue is long closed. Best to create a new issue in the issue queue.

Production build 0.71.5 2024