3

I have developed a custom Drupal field.

All works fine. We are already using the field in production for a year. But the status report for exactly this field says:

Mismatched entity and/or field definitions

I would like to get rid of that message. It gives me a bad feeling about the reliability of my Drupal installation.

I could write an update hook if I knew in detail what is wrong.

How can I find out what exactly does not match?

2
  • 1
    It's unclear why you want to get rid of this message. Normally you develop a new module and then deploy it, which means install the module in different environments and import configurations. If this is about an already deployed module you need an update hook for the database schema updates. If you want to get rid of this message in your dev environment you can either re-install the module or use drupal.org/project/devel_entity_updates
    – 4k4
    Sep 15 at 7:57
  • Thanks for you comment, @4k4. I have edited my answer and explained that the field is in use in production and that the error message makes me fear that the Drupal installation is not reliable. Sep 15 at 8:47
3

OK, if this happened in production you probably had a code change in FieldItemInterface::schema().

The most detailed information you get is from

\Drupal::entityDefinitionUpdateManager()->getChangeList()

returning a list of entity fields affected and the status 1,2 or 3. If your field is listed with 2 (DEFINITION_UPDATED) then check your code history for schema changes. If you don't have a code history you could check the current state of the database table(s). If you don't see the changes then install the module on a fresh site and compare the created tables.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.