diff --git a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php index 41beeaf..6d3b22d 100644 --- a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php +++ b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php @@ -266,10 +266,12 @@ public function resetCache(array $entities = NULL) { * TRUE if the view mode can be cached, FALSE otherwise. */ protected function isViewModeCacheable($view_mode) { - // The isset() checks below are necessary because 'default' is not an actual - // view mode. + if ($view_mode == 'default') { + // The 'default' is not an actual view mode. + return TRUE; + } $view_modes_info = entity_get_view_modes($this->entityType); - $view_mode_is_cacheable = !isset($view_modes_info[$view_mode]) || (isset($view_modes_info[$view_mode]) && $view_modes_info[$view_mode]['cache']); - return $view_mode_is_cacheable; + return !empty($view_modes_info[$view_mode]['cache']); } + } diff --git a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php index dc96922..39dff2d 100644 --- a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php +++ b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php @@ -109,6 +109,10 @@ public function form(array $form, array &$form_state) { * TRUE if the display mode exists, FALSE otherwise. */ public function exists($entity_id, array $element, array $form_state) { + // Do not allow to add internal 'default' view mode. + if ($entity_id == 'default') { + return TRUE; + } return (bool) $this->queryFactory ->get($this->entity->entityType()) ->condition('id', $element['#field_prefix'] . $entity_id)