diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php index d76c132..337cd1e 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php @@ -124,10 +124,12 @@ protected function installedStorageSchema() { * {@inheritdoc} */ public function requiresEntityStorageSchemaChanges(EntityTypeInterface $entity_type, EntityTypeInterface $original) { - return - $this->hasSharedTableStructureChange($entity_type, $original) || - // Detect changes in key or index definitions. - $this->getEntitySchemaData($entity_type, $this->getEntitySchema($entity_type, TRUE)) != $this->loadEntitySchemaData($original); + $shared = $this->hasSharedTableStructureChange($entity_type, $original); + // Detect changes in key or index definitions. + $new = $this->getEntitySchemaData($entity_type, $this->getEntitySchema($entity_type, TRUE)); + $old = $this->loadEntitySchemaData($original); + $schema = $new != $old; + return $shared || $schema; } /** @@ -143,10 +145,10 @@ public function requiresEntityStorageSchemaChanges(EntityTypeInterface $entity_t * a table has been renamed. */ protected function hasSharedTableStructureChange(EntityTypeInterface $entity_type, EntityTypeInterface $original) { - return - $entity_type->isRevisionable() != $original->isRevisionable() || - $entity_type->isTranslatable() != $original->isTranslatable() || - $this->hasSharedTableNameChanges($entity_type, $original); + $revisionable = $entity_type->isRevisionable() != $original->isRevisionable(); + $translatable = $entity_type->isTranslatable() != $original->isTranslatable(); + $changes = $this->hasSharedTableNameChanges($entity_type, $original); + return $revisionable || $translatable || $changes; } /** diff --git a/core/modules/contact/contact.install b/core/modules/contact/contact.install index 202140f..eaaef98 100644 --- a/core/modules/contact/contact.install +++ b/core/modules/contact/contact.install @@ -4,7 +4,7 @@ * Update schema. */ function contact_update_8001() { - $entity_type = \Drupal::entityTypeManager()->getStorage('message')->getEntityType(); + $entity_type = \Drupal::entityTypeManager()->getStorage('contact_message')->getEntityType(); \Drupal::service('system.entity_schema_updater')->createTables($entity_type); \Drupal::service('system.entity_schema_updater')->addRevisionField($entity_type); } diff --git a/core/modules/system/src/EntitySchemaUpdater.php b/core/modules/system/src/EntitySchemaUpdater.php index 0dacfd8..9adfd84 100644 --- a/core/modules/system/src/EntitySchemaUpdater.php +++ b/core/modules/system/src/EntitySchemaUpdater.php @@ -5,6 +5,7 @@ use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema; +use Drupal\Core\Entity\Sql\SqlEntityStorageInterface; use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\StringTranslation\TranslatableMarkup; @@ -16,7 +17,9 @@ class EntitySchemaUpdater implements EntitySchemaUpdaterInterface { public function createTables(EntityTypeInterface $entity_type) { $entity_type_manager = \Drupal::entityTypeManager(); $storage = $entity_type_manager->getStorage($entity_type->id()); - $storage->onEntityTypeCreate($entity_type); + if ($storage instanceof SqlEntityStorageInterface) { + $storage->onEntityTypeCreate($entity_type); + } } public function addRevisionField(EntityTypeInterface $entity_type) { @@ -61,12 +64,9 @@ public function addRevisionField(EntityTypeInterface $entity_type) { $entity_field_manager = \Drupal::service('entity_field.manager'); /** @var \Drupal\Core\Field\FieldStorageDefinitionInterface[] $definitions */ - $definitions = $entity_field_manager->getFieldStorageDefinitions($entity_type->id()); - foreach ($definitions as $definition) { - if ($definition->isTranslatable() && $definition->isBaseField()) { - $definition->setRevisionable(TRUE); - } - } + $entity_field_manager->clearCachedFieldDefinitions(); + + \Drupal::service('entity.last_installed_schema.repository')->setLastInstalledDefinition($entity_type); } }