I’m developing a site in Drupal 8 in Acquia Dev Desktop 2 on Windows 10. After updating to 8.5.0-beta1 I noticed this error on my status page (although it may have been there earlier in 8.4.4):
ENTITY/FIELD DEFINITIONS Mismatched entity and/or field definitions The following changes were detected in the entity type and field definitions. Custom menu link The menu_link_content.field_most_common_name field needs to be updated.
It’s possible this error came from the Menu Item Extras module, which I had installed a couple of months ago, but since deleted.
Following popular advice, I ran drush entity-updates
. That did not cure the problem. The output (typed manually) from my CMD window is below:
menu_link_content entity type : The menu_link_content.field_most_common_name field needs to be updated. Do you wish to run all pending updates? (y/n): y Drupal\Core\Entity\EntityStorageException: Exception thrown while performing a schema update. SQLSTATE[42522]: column not found: 1054 unknown column [error] 'field_most_common_name_argument' in 'where clause': SELECT 1 AS expression FROM {menu_link_content__field_most_common_name} t WHERE (field_most_common_name_target_id IS NOT NULL) OR (field_most_common_name_display_id IS NOT NULL) OR (field_most_common_name_argument IS NOT NULL) OR (field_most_common_name_title IS NOT NULL) OR (field_most_common_name_data IS NOT NULL) LIMIT 1 OFFSET 0; Array ( ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->wrapSchemaException() (line 1535 of C:\Users\Nick\Sites\devdesktop\drupal\core\lib\Drupal \Core\Entity\Sql\SqlContentEntityStorage.php). Failed: Drupal\core\EntityStorageException: !message in Drupal\Core\Entity\Sql\SqlContentEntityStorage->wrapSchemaException() (line 1535 of C:\Users\Nick\Sites\devdesktop\drupal\core\lib\Drupal\Core\Entity \Sql\SqlContentEntityStorage.php). [error] Cache rebuild complete. [ok] Finished performing updates. [ok]
Based on the 2nd answer here and this reference, I have made a custom module called “Database Fix” with the following content in the database_fix.module
file. I am not a coder, so there is plenty of guesswork involved here:
<?php /** * Fix database by updating menu_link_content.field_most_common_name field * */ function database_fix_update_8501() { $ manager = \Drupal::entityDefinitionUpdateManager(); if ($ field = $ manager->getFieldStorageDefinition('field_most_common_name', 'menu_link_content')) { $ manager->updateFieldStorageDefinition($ field); } }
I enabled the module, refreshed pages and ran update.php
, but it didn’t work.