Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The Status report (/admin/reports/status#error) generates the following error:
Errors found: ENTITY/FIELD DEFINITIONS
Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.
Workflow scheduled transition > The Workflow scheduled transition entity type needs to be updated.
Workflow executed transition > The Workflow executed transition entity type needs to be updated.
How to do that?
Comments
Comment #2
johnvThis is also reported here: #2601762: Mismatched entity and/or field definitions after upgrade from RC1 to RC2
And gives the following resolutions:
- drush entity-updates
- add PHP:
Comment #3
johnvExcuting the above gives the following result:
Comment #4
dabley CreditAttribution: dabley as a volunteer commentedI ran drush entity-updates, and this successfully updated "Workflow scheduled transition", but failed to update "Workflow executed transition" - and that's because my workflow_transition_schedule table is empty, while my workflow_transition_history table has data in it.
I realise that the issue of not being able to update storage definitions of entity types that already have some data is a generic problem for Drupal 8. However, I would appreciate some advice from those who are more knowledgeable than me. When the 'Mismatched entity and/or field definitions' error message is shown in the status report, even after running drush entity-updates, what should users do?
Comment #5
dabley CreditAttribution: dabley as a volunteer commentedComment #6
johnvMy test system also shows these errors, but there does not seem to be any problem.
Perhaps an explcite DB update is necessary in an update_hook??
Comment #7
dabley CreditAttribution: dabley as a volunteer commentedI found that the following is a workaround for this error:
1. Make a backup copy of workflow_transition_history table. This can be done by exporting the table, e.g. in PHPMyadmin, or by running SQL such as:
Create table bak_workflow_transition_history as select * FROM workflow_transition_history;
2. Delete all the rows in the table. e.g. with the SQL:
Truncate table workflow_transition_history;
3. Run
drush entity-updates
. This should complete without error. I found no change in the definition of the table.4. Re-import the data back into the table, e.g. by importing, or running SQL such as:
Insert into workflow_transition_history select * from bak_workflow_transition_history;
5. Get rid of the backup table:
Drop table bak_workflow_transition_history;
Running the admin status report now shows there's no longer an error.
I am unable to test that the re-imported data functions correctly, as the Workflow module doesnt currently support a History Tab for entities other than Nodes and Taxonomy terms (and my workflow is not on one of these entities).
I was surprised that after running "drush entity-updates" the table definition remained exactly the same, as far as I could see. I wonder what actually got updated? (I also ran a "drush cex" - but this showed nothing to have changed either.)
In my case, I had no rows in the workflow_transition_schedule table, so I didnt need to do anything special with that. But if you do have rows in that table, the above approach might also work. (I have compared the pre- and post-update table definitions, and they look the same too.)
Others' perspectives on this would be welcome.
Comment #8
dabley CreditAttribution: dabley as a volunteer commentedJohnv, yes, I can well believe that there are no functional problems - but I dont feel happy simply ignoring an error message. Especially if a client takes a look at the status report, and gets the impression that I'm exposing them to risk.
This issue https://www.drupal.org/project/drupal/issues/2542748 from two years ago (and marked as Fixed) discusses the generic problem. I haven't read all the comments in that post, but the thrust seems to be that modules should supply their own hook_update_N() functions in order to run entity schema updates.
So, it seems to me that a proper solution would - as you say - be for the Workflow module to have a suitably implemented hook_update_N() function.
Comment #9
johnvThere is no patch attached, hence back to active.
Comment #10
geek-merlinLooks like an update issue. And unclear if still an issue.
Comment #11
AswathyAjish CreditAttribution: AswathyAjish commentedThis issue still exist.
My drupal version is 8.6.1 and my workflow module version is 8.x-1.1. Now I have upgraded my PHP version to 7. Then the following error message is shown in the status report :
I tried to run drush entity-updates command, but the following error is shown :
Then I deleted all nodes of the workflow entity type and tried to execute drush entity-updates command. Then it executed successfully and the error message from status report is gone. (I have done this in my development server)
But I could not delete the nodes in my production server, so is there any option to execute drush entity-updates command without deleting the existing nodes?
Comment #12
AswathyAjish CreditAttribution: AswathyAjish commentedComment #13
johnvSee this change record abut this message: https://www.drupal.org/node/2554101
Maintainer, the change notice at https://www.drupal.org/node/2554097 outlines the steps you need to take.
Comment #14
dabley CreditAttribution: dabley as a volunteer commentedAswathyAjish - did you try the workaround I posted?
Comment #15
johnvComment #16
e5sego CreditAttribution: e5sego commentedFor me, the workaround from https://www.drupal.org/project/2157705/issues/3155488#comment-14143361 worked with existing content.
Comment #17
keshavv CreditAttribution: keshavv as a volunteer and at Axelerant for Drupal India Association commentedThe solution mentioned in #16 works for me. Here is the short snippet.
Execute this code in an update hook.
$entity_type_manager = \Drupal::entityTypeManager();
$entity_type_manager->clearCachedDefinitions();
$entity_type_ids = [];
$change_summary = \Drupal::service('entity.definition_update_manager')->getChangeSummary();
foreach ($change_summary as $entity_type_id => $change_list) {
$entity_type = $entity_type_manager->getDefinition($entity_type_id);
\Drupal::entityDefinitionUpdateManager()->installEntityType($entity_type);
$entity_type_ids[] = $entity_type_id;
}