0

I installed the Rabbit Hole module in Drupal 9. I was immediately greeted with this message on the status page:

Mismatched entity and/or field definitions

The following changes were detected in the entity type and field definitions.
User
The Rabbit Hole action field needs to be installed.
The Rabbit Hole redirect path. field needs to be installed.
The Rabbit Hole redirect response code field needs to be installed.
The Rabbit Hole redirect fallback action field needs to be installed.

Everyone seems to say run devel entity-updates, but that module page itself says:

The goal of this module is to have a quick way to apply schema updates while developing new entity types and ending up incrementally adding/removing/changing entity type/field definitions.

When these changes are part of an official release (and not in the scope of a code development session), they should absolutely rely on DB update functions, as explained in the CR above, because that's the only way the entity schema update process can be predictable and reliable.

For this reason, this module depends on Devel and is not meant to be enabled in production environments or relied upon in deployment workflows, see #3082442: Why not meant to be enabled in production environments? for more details.

So, it should not be used or ran in production? Running it locally produces no visible change to configuration exports. So how would you get this done on a production database?

Instead, people say these updates should occur in an update hook. What does that mean? Is this burden on the developer or the user to do? I have seen this from time to time with contributed modules, and do not understand if devel entity-updates will "fix" (correctly fix) this issue, or if there is a concrete way to do this change.

2
  • You don't need an update hook to install or uninstall a module containing a field definition. The last issue concerning this was solved in Drupal 8.5. See drupal.org/project/drupal/issues/2282119. Update hooks are for changes in already installed modules.
    – 4uk4
    Feb 17, 2022 at 17:26
  • Does running the entity updates command remove the message from your status page locally?
    – sonfd
    Feb 17, 2022 at 22:09

2 Answers 2

1

You don't get "Mismatched entity and/or field definitions" after installing/uninstalling a contrib module adding base fields to existing entities.

Steps to reproduce:

  • composer require 'drupal/rabbit_hole:^1.0@beta'
  • enable Rabbit Hole main module and Rabbit Hole users submodule
  • the table users_field_data contains the 4 new fields
  • Status page is clear
  • edit a user with individual rabbit hole settings to fill the fields with data
  • check the database, data is stored
  • uninstall the module
  • fields are moved from users_field_data to separate field_deleted_data_* tables
  • run cron
  • field_deleted_data_* are purged from the database

If the module doesn't install/uninstall correctly like this, rollback and test it first on a local copy of the site until it works. Don't use a dev tool like devel entity-updates on production data. Even more so for a module still in beta changing core entity tables.

3
  • Is that normal though? Or is this specific to that module?
    – Kevin
    Feb 18, 2022 at 14:46
  • This exact behavior is normal for all modules adding base fields to existing entities.
    – 4uk4
    Feb 18, 2022 at 14:52
  • Odd... I wonder what triggered this message for me. I just recall enabling it.
    – Kevin
    Feb 18, 2022 at 15:48
0

I was able to resolve this issue by doing the following:

  1. Note the name(s) of the field(s) in the error message on the status page
  2. Go to /admin/reports/fields and search for the field(s) in question
  3. Click on the link in the "Used In" column for each field in question. That will take you to the "Manage fields" page for the content type where the field is used.
  4. Click "Edit" next to the name of the field in question.
  5. Click "Save" to update the field.

I didn't need to do anything other than click "Save". That resolved the error.

1
  • This didn't work for my example. I was confident it would though! :)
    – Christian
    Sep 26, 2023 at 0:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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