Missing 'full' display view causes no cache debug in HTML

Created on 19 February 2024, about 1 year ago

Problem/Motivation

When displaying any group entity (url/group/), the debug information (when enabled) in the HTML is not shown.
The expected output could be something like that:

<!-- START RENDERER -->
<!-- CACHE-HIT: No -->
<!-- CACHE TAGS:
   * group_view
   * group:2
   * config:system.site
-->
<!-- CACHE CONTEXTS:
   * url.site
   * languages:language_interface
   * theme
   * user.permissions
   * url.path
-->
<!-- CACHE KEYS:
   * entity_view
   * group
   * 2
   * full
-->
<!-- CACHE MAX-AGE: -1 -->
<!-- PRE-BUBBLING CACHE TAGS:
   * group_view
   * group:2
-->
<!-- PRE-BUBBLING CACHE CONTEXTS:
   * url.site
   * languages:language_interface
   * theme
   * user.permissions
-->
<!-- PRE-BUBBLING CACHE KEYS:
   * entity_view
   * group
   * 2
   * full
-->
<!-- PRE-BUBBLING CACHE MAX-AGE: -1 -->
<!-- RENDERING TIME: 0.209016085 -->
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'group' -->
<!-- FILE NAME SUGGESTIONS:
   ▪️ group--2--full.html.twig
   ▪️ group--2.html.twig
   ▪️ group--egm-event--full.html.twig
   ✅ group--egm-event.html.twig
   ▪️ group--full.html.twig
   ▪️ group.html.twig
-->
<!-- 💡 BEGIN CUSTOM TEMPLATE OUTPUT from 'themes/custom/egm_theme/templates/content/group.html.twig' -->

but by default we have something like:

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'group' -->
<!-- FILE NAME SUGGESTIONS:
   * group--2--full.html.twig
   * group--2.html.twig
   * group--egm-event--full.html.twig
   x group--egm-event.html.twig
   * group--full.html.twig
   * group.html.twig
-->

If we devel the entity (/devel/render/group/): we can also see

  "#view_mode" => "full"
  "#cache" => array:3 [▼
    "tags" => array:2 [▼
      0 => "group_view"
      1 => "group:4"
    ]
    "contexts" => []
    "max-age" => -1
  ]
  "#theme" => "group"

if i dig in the GroupViewBuider / EntityViewBuilder: $this->isViewModeCacheable($view_mode)
returns FALSE for view mode 'full', and inside isViewModeCacheable() in the entityViewBuilder class,
in a vanilla installation $this->entityDisplayRepository->getViewModes($this->entityTypeId) could return empty as no view modes are created (/admin/structure/display-modes/view)

If a 'Full content' view with id 'full' is created, then

If we devel the entity (/devel/render/group/): we can also see

  "#view_mode" => "full"
  "#cache" => array:5 [▼
    "tags" => array:2 [▶]
    "contexts" => []
    "max-age" => -1
    "keys" => array:4 [▶]
    "bin" => "render"
  ]
  "#theme" => "group"

and the debug in the HTML now is correct

Steps to reproduce

In the problem explained

Proposed resolution

I think the easiest could be to create the 'full' display view when the module is being installed.
The view does not need to be enabled, just needs to exists as it seems somewhere it treats the 'default' as 'full' and voila.

I was comparing the code with the group module, and they have that view created during installation (event it is not enabled)

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

3.2

Component

Code

Created by

🇧🇪Belgium gorkagr

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024