diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php index 91ca92b..c62fc06 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php @@ -271,6 +271,13 @@ public function setEntityType(EntityTypeInterface $entity_type) { public function getTableMapping(array $storage_definitions = NULL) { $table_mapping = $this->tableMapping; + // If we are using our internal storage definitions, which is our main use + // case, we can statically cache the computed table mapping. If a new set + // of field storage definitions is passed,for instance when comparing old + // and new storage schema, we just compute the table mapping but skip any + // caching. + // @todo Clean-up this in https://www.drupal.org/node/2274017 so we can + // easily instantiate a new table mapping whenever needed. if (!isset($this->tableMapping) || $storage_definitions) { $definitions = $storage_definitions ?: $this->entityManager->getFieldStorageDefinitions($this->entityTypeId); $base_field_definitions = $this->entityManager->getBaseFieldDefinitions($this->entityTypeId); @@ -382,6 +389,8 @@ public function getTableMapping(array $storage_definitions = NULL) { } } + // Cache the computed table mapping only if we are using our internal + // storage definitions. if (!$storage_definitions) { $this->tableMapping = $table_mapping; } diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php index 168b1bd..37d2067 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php @@ -418,7 +418,7 @@ protected function getEntitySchema(ContentEntityTypeInterface $entity_type, $res } foreach ($table_mapping->getFieldNames($table_name) as $field_name) { if (!isset($storage_definitions[$field_name])) { - throw new FieldException(String::format('Fieled storage definition for "@field_name" could not be found.', array('@field_name' => $field_name))); + throw new FieldException(String::format('Field storage definition for "@field_name" could not be found.', array('@field_name' => $field_name))); } // Add the schema for base field definitions. elseif ($table_mapping->allowsSharedTableStorage($storage_definitions[$field_name])) {