Drupal 8: Mismatched entity and/or field definitio

2019-09-10 03:14发布

While trying to understand why my view is not displaying, I noticed the following error in the log:

enter image description here

I do not think it is possible to delete the URL alias from Taxonomy terms. At least I cannot find how to do this. I have, however gone through ALL of my taxonomy terms and removed the value for this field.

I have also done the following with Pathauto: enter image description here

Also, I have checked the report located at admin/reports/fields and can confirm that there are no entities that use a field called URL alias.

I have gone through each content item and ensured that they have the following setting (anyone know how to do this in bulk?). But still the error remains. enter image description here

Anyone know then how I can fix this strange error?

2条回答
2楼-- · 2019-09-10 03:26

Since https://www.drupal.org/node/2554097, the magic in Drupal core that took care of updating entity definitions is gone. drush updb --entiy-updates is an alternative to this but it is not a silver bullet. Instead, it is safer to write database updates.

Taking the screenshot at the top as an example, here is a database update that would delete those two field definitions:

/**
 * Fix taxonomy and node field definitions.
 *
 */
function mymodule_update_8101() {
  $manager = \Drupal::entityDefinitionUpdateManager();

  if ($field = $manager->getFieldStorageDefinition('alias', 'node')) {
    $manager->uninstallFieldStorageDefinition($field);
  }

  if ($field = $manager->getFieldStorageDefinition('alias', 'term')) {
    $manager->uninstallFieldStorageDefinition($field);
  }
}

Have a look at the rest of the available methods at https://www.drupal.org/node/2554097 in order to write database updates for each scenario.

查看更多
三岁会撩人
3楼-- · 2019-09-10 03:36

Im not entirely sure what this command does, but it fixed the error:

drush updb --entity-updates
查看更多
登录 后发表回答