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.
A couple of months ago I had Menu Item Extras 8.x-2.0-rc1 installed. It seems to me that this error is related to that, although I can't be sure. "Most Common Name" would be the name of one of the fields I attempted to add to a menu item.
I have tried many things to resolve this:
1. I reinstalled Menu Item Extras, made a menu, tried to make a field with the same name "Most Common Name" (failed), and uninstalled correctly.
2. 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]
3. I also tried the index.php modification explained in the accepted answer here, but that did not work either.
4. Using phpMyAdmin I deleted the entries containing field_most_common_name
from the config etc. tables in the database. That left me with worse errors (e.g. "The Entity ID field needs to be installed.") so I reinstalled from a backup.
5. 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 enabled the module, refreshed pages and ran update.php
, but it didn't work. 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);
}
}
6. I tried the above code but with $manager->uninstallFieldStorageDefinition($field);
instead of $manager->updateFieldStorageDefinition($field);
but that didn't work.
Is this a Menu Item Extras issue, and is there anything else I can do to fix the problem?