Missing hook_install to update field storage definition for menu_link_content

Created on 15 May 2025, 3 days ago

Problem/Motivation

The hook_install which update field definitions of menu_link_content is missing.

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db.menu_link_content__menu_item_roles' doesn't exist: SELECT "t".* FROM "menu_link_content__menu_item_roles" "t" WHERE ("entity_id" IN (:db_condition_placeholder_0)) AND ("deleted" = :db_condition_placeholder_1) AND ("langcode" IN (:db_condition_placeholder_2, :db_condition_placeholder_3, :db_condition_placeholder_4)) ORDER BY "delta" ASC; Array ( [:db_condition_placeholder_0] => 2 [:db_condition_placeholder_1] => 0 [:db_condition_placeholder_2] => fr [:db_condition_placeholder_3] => und [:db_condition_placeholder_4] => zxx ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->loadFromDedicatedTables() (line 1242 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Step to reproduce

  1. Update the core.extension and add menu_item_role_access.
  2. Import the configuration with drush cim.
  3. Notice that the table menu_link_content__menu_item_roles is not present.

Solution

As mentionned is this issue : https://www.drupal.org/node/3034742 #Updating an existing field storage definition
Since Drupal 8.7, base field is not updated automatically so we need to implement hook_install to update base field definition.
Implement a hook_install() to update the field definitions for menu_link_content.

Remaining task

Test the solution

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024