Drupal 8: Mismatched entity and/or field definitions

爱⌒轻易说出口 提交于 2020-01-07 02:25:29

问题


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

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:

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.

Anyone know then how I can fix this strange error?


回答1:


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

drush updb --entity-updates



回答2:


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.



来源:https://stackoverflow.com/questions/37214387/drupal-8-mismatched-entity-and-or-field-definitions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!