diff -u b/core/modules/views/src/Entity/View.php b/core/modules/views/src/Entity/View.php --- b/core/modules/views/src/Entity/View.php +++ b/core/modules/views/src/Entity/View.php @@ -5,6 +5,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Core\Cache\Cache; use Drupal\Core\Config\Entity\ConfigEntityBase; +use Drupal\Core\Entity\ContentEntityTypeInterface; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Language\LanguageInterface; @@ -294,15 +295,14 @@ $displays = $this->get('display'); // Fix wrong table names for entity revision metadata fields. - foreach ($displays as $display => &$display_data) { + foreach ($displays as $display => $display_data) { if (isset($display_data['display_options']['fields'])) { - foreach ($display_data['display_options']['fields'] as $property_name => &$property_data) { + foreach ($display_data['display_options']['fields'] as $property_name => $property_data) { if (isset($property_data['entity_type']) && isset($property_data['field']) && isset($property_data['table'])) { $entity_type = $this->entityTypeManager()->getDefinition($property_data['entity_type']); - // We only need to update the table name for revisionable and - // translatable entity types, otherwise the view is already using - // the correct table. - if (is_subclass_of($entity_type->getClass(), FieldableEntityInterface::class) && $entity_type->isRevisionable() && $entity_type->isTranslatable()) { + // We need to update the table name for revisionable and types, + // otherwise the view is already using the correct table. + if (($entity_type instanceof ContentEntityTypeInterface) && is_subclass_of($entity_type->getClass(), FieldableEntityInterface::class) && $entity_type->isRevisionable()) { $revision_metadata_fields = $entity_type->getRevisionMetadataKeys(); // @see \Drupal\Core\Entity\Sql\SqlContentEntityStorage::initTableLayout() $revision_table = $entity_type->getRevisionTable() ?: $entity_type->id() . '_revision'; @@ -310,15 +310,13 @@ // Check if this is a revision metadata field and if it uses the // wrong table. if (in_array($property_data['field'], $revision_metadata_fields) && $property_data['table'] != $revision_table) { - $property_data['table'] = $revision_table; + $displays[$display]['display_options']['fields'][$property_name]['table'] = $revision_table; } } } } - unset($property_data); } } - unset($display_data); // Sort the displays. ksort($displays);