diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php index 9c498b2..0543651 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php @@ -356,7 +356,7 @@ public function getTableMapping(array $storage_definitions = NULL) { // Add dedicated tables. $dedicated_table_definitions = array_filter($definitions, function (FieldStorageDefinitionInterface $definition) use ($table_mapping) { - return $table_mapping->requiresDedicatedTableStorage($definition) && $definition->isBaseField(); + return $table_mapping->requiresDedicatedTableStorage($definition); }); $extra_columns = array( 'bundle', @@ -1586,9 +1586,10 @@ public function finalizePurge(FieldStorageDefinitionInterface $storage_definitio * {@inheritdoc} */ public function countFieldData($storage_definition, $as_bool = FALSE) { - // The storage definition might be different stored to the one in the DB, so - // fetch the table mapping from an up to date one, using the passed in - // storage definition. + // The table mapping contains stale data during a request when a field + // storage definition is added, so bypass the internal storage definitions + // and fetch the table mapping using the passed in storage definition. + // @todo Fix this in https://www.drupal.org/node/2705205. $storage_definitions = $this->entityManager->getFieldStorageDefinitions($this->entityTypeId); $storage_definitions[$storage_definition->getName()] = $storage_definition; $table_mapping = $this->getTableMapping($storage_definitions); diff --git a/core/modules/views/src/EntityViewsData.php b/core/modules/views/src/EntityViewsData.php index d8dc82f..e41efa9 100644 --- a/core/modules/views/src/EntityViewsData.php +++ b/core/modules/views/src/EntityViewsData.php @@ -235,7 +235,7 @@ public function getViewsData() { // Load all typed data definitions of all fields. This should cover each of // the entity base, revision, data tables. $field_definitions = $this->entityManager->getBaseFieldDefinitions($this->entityType->id()); - if ($table_mapping = $this->storage->getTableMapping()) { + if ($table_mapping = $this->storage->getTableMapping($field_definitions)) { // Fetch all fields that can appear in both the base table and the data // table. $entity_keys = $this->entityType->getKeys();