Problem/Motivation
In \Drupal\external_entities\Entity\ExternalEntityType::postSave, the module does not create the database schema for external entity types when they are created. As a result, when \Drupal\Core\Entity\EntityDefinitionUpdateManager::getChangeList identifies entity type definitions that do not match what's in the database schema, external entity types get flagged.
$this->entityLastInstalledSchemaRepository->getLastInstalledDefinition($entity_type_id) always returns NULL. This is what triggers the "Mismatched entity and/or field definitions" error on the status page.
Proposed resolution
Modify \Drupal\external_entities\Entity\ExternalEntityType::postSave to create database schema when an external entity type is created. The code in this patch was more or less lifted from ECK. One key difference is that the patch will not include \Drupal::entityDefinitionUpdateManager()->applyUpdates();, which is referenced in #3 below. If entity definitions are changed, then they should be updated in the schema at that time. Also, the applyUpdates method is deprecated and is being removed because it's dangerous. When it runs, it's not scoped. Like at all.
Remaining tasks
- Submit patch
- Community testing and review
User interface changes
None.
API changes
None.
Data model changes
We're technically not looking at a data model change, but the patch will include an update script to catch any existing external entity types and create database schema for them.
Release notes snippet
TBD
Original report by clemens.tolboom
Problem/Motivation
After configuring an External Entity /admin/reports/status reports an error
Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.
My External Entity 1
- The My External Entit entity type needs to be installed.
Proposed resolution
Not sure whether this is for a recent Drupal core version. I saw it for 8.6.x and now for 8.7.2-dev
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | external_entities-create_db_schema-3056426-5.patch | 2.65 KB | chris burge |
Comments
Comment #2
chris burge commentedI'm seeing this, too.
I'll try to dig into this in next few days.
Comment #3
chris burge commentedI've resolved the issue and expect to be posting a patch shortly. I borrowed some code from ECK, but they're using \Drupal::entityDefinitionUpdateManager()->applyUpdates(), which is deprecated, so I'm working through that right now.
Comment #4
chris burge commentedComment #5
chris burge commentedComment #7
clemens.tolboomLooks good to me ... committed.
Thanks!