Invalid theme file name suggestions generated

Created on 6 February 2024, 5 months ago

Problem/Motivation

External entities with a UUID as ID or any ID containing characters not accepted by hook_theme_suggestions_HOOK() generate unusable template name suggestions. The template name suggestion doesn't work, and could be hard to figure out why. Twig debugging makes notice of this.

it looks like this when twig debugging is enabled:

<!--- 
   INVALID FILE NAME SUGGESTIONS:
   See https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!theme.api.php/function/hook_theme_suggestions_alter
   external_entity__b719a2fa-e401-4c97-b0b2-c33cb2a97693__full
   external_entity__b719a2fa-e401-4c97-b0b2-c33cb2a97693 
--->

Steps to reproduce

  1. Configure an external entity using a UUID or other form of ID with illegal template name characters
  2. Enable twig debugging
  3. Visit a page containing an external entity, like the detail page

Proposed resolution

sanitize the ID while generating theme suggestions.

πŸ› Bug report
Status

Needs review

Component

Code

Created by

πŸ‡³πŸ‡±Netherlands pefferen

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

Merge Requests

Comments & Activities

Production build 0.69.0 2024