diff --git a/core/lib/Drupal/Core/Entity/EntityStorageBase.php b/core/lib/Drupal/Core/Entity/EntityStorageBase.php index b8f98d0..5d2c2aa 100644 --- a/core/lib/Drupal/Core/Entity/EntityStorageBase.php +++ b/core/lib/Drupal/Core/Entity/EntityStorageBase.php @@ -460,6 +460,8 @@ public function loadByProperties(array $values = array()) { * {@inheritdoc} */ public function getQuery($conjunction = 'AND') { + // Access the service directly rather than entity.query factory so the + // storage's current entity type is used. return \Drupal::service($this->getQueryServicename())->get($this->entityType, $conjunction); } diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php index 0b1aeb9..d3087b7 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php @@ -178,10 +178,13 @@ public function requiresFieldStorageSchemaChanges(FieldStorageDefinitionInterfac * {@inheritdoc} */ public function requiresEntityDataMigration(EntityTypeInterface $entity_type, EntityTypeInterface $original) { + // If the original storage has existing entities, or it is impossible to + // determine if that is the case, require entity data to be migrated. $original_storage_class = $original->getStorageClass(); if (!class_exists($original_storage_class)) { return TRUE; } + // Use the original entity type since the storage has not been updated. $original_storage = $this->entityManager->createHandlerInstance($original_storage_class, $original); return $original_storage->hasData(); }