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

Comments

clemens.tolboom created an issue. See original summary.

chris burge’s picture

I'm seeing this, too.

  • Drupal 8.7.0
  • External Entities 8.x-2.0-alpha1

I'll try to dig into this in next few days.

chris burge’s picture

I'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.

chris burge’s picture

Title: Status report 'Mismatched entity and/or field definitions' » Create database schema when external entity types are created
Issue summary: View changes
chris burge’s picture

Status: Active » Needs review
StatusFileSize
new2.65 KB

clemens.tolboom’s picture

Status: Needs review » Fixed

Looks good to me ... committed.

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.