diff --git a/core/modules/views/src/Tests/FieldApiDataTest.php b/core/modules/views/src/Tests/FieldApiDataTest.php index b538aed..9778fbb 100644 --- a/core/modules/views/src/Tests/FieldApiDataTest.php +++ b/core/modules/views/src/Tests/FieldApiDataTest.php @@ -155,7 +155,7 @@ protected function setUp() { * * We check data structure for both node and node revision tables. */ - function ptestViewsData() { + function testViewsData() { $views_data = $this->container->get('views.views_data'); $data = array(); diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 5316b7b..787e9fb 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -468,29 +468,31 @@ function views_add_contextual_links(&$render_element, $location, ViewExecutable } /** - * Implements hook_entity_create(). + * Implements hook_entity_insert(). */ -function views_entity_create(EntityInterface $entity) { - if ($entity->getEntityTypeId() !== 'field_config' && $entity->getEntityTypeId() !== 'base_field_override') { - return; - } - Views::viewsData()->clear(); +function views_entity_insert(EntityInterface $entity) { + views_invalidate_field_data($entity); } /** * Implements hook_entity_update(). */ function views_entity_update(EntityInterface $entity) { - if ($entity->getEntityTypeId() !== 'field_config' && $entity->getEntityTypeId() !== 'base_field_override') { - return; - } - Views::viewsData()->clear(); + views_invalidate_field_data($entity); } /** * Implements hook_entity_delete(). */ function views_entity_delete(EntityInterface $entity) { + views_invalidate_field_data($entity); +} + +/** + * Invalidates field data for 'field_config' and 'base_field_override' entities. + * @param \Drupal\Core\Entity\EntityInterface $entity + */ +function views_invalidate_field_data(EntityInterface $entity) { if ($entity->getEntityTypeId() !== 'field_config' && $entity->getEntityTypeId() !== 'base_field_override') { return; } diff --git a/core/modules/views/views.views.inc b/core/modules/views/views.views.inc index 1211c4e..30b3d23 100644 --- a/core/modules/views/views.views.inc +++ b/core/modules/views/views.views.inc @@ -359,11 +359,13 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora } } - // If the field is translatable on all the bundles, there will be a join on the langcode. + // If the field is translatable on all the bundles, there will be a join on + // the langcode. if (!empty($translatable_configs) && empty($untranslatable_configs)) { $translation_join_type = 'language'; } - // If the field is translatable only on certain bundles, there will be a join on langcode OR bundle name. + // If the field is translatable only on certain bundles, there will be a + // join on langcode OR bundle name. elseif (!empty($translatable_configs) && !empty($untranslatable_configs)) { foreach ($untranslatable_configs as $config) { $untranslatable_config_bundles[] = $config->getTargetBundle();