Template preprocess functions are called for multiple scenarios

Created on 29 October 2019, over 5 years ago
Updated 2 June 2025, 5 days ago

Please adjust the title if required.

I found out that template_preprocess_HOOK functions are called for multiple scenarios.

For example the issue I ran into:

I defined a template using a theme.layouts.yml file:

comment:
  label: Comment layout
  category: Custom
  template: templates/layouts/comment
  regions:
    user:
      label: User
    content:
      label: Content

When this layout is being rendered, the template_preprocess_comment functions is called in the comment module resulting in a fatal error.

($comment = $variables['elements']['#comment']; There is no such thing.)

While this might be the desired behaviour. I feel the outcome here is wrong.

Kind regards,
Harings Rob

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component

layout_discovery.module

Created by

πŸ‡§πŸ‡ͺBelgium harings_rob

Live updates comments and jobs are added and updated live.
  • Blocks-Layouts

    Blocks and Layouts Initiative. See the #2811175 Add layouts to Drupal issue.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    This came up as a daily BSI target

    First we need to check if still an issue in D11.

    If so then lets update the issue summary with the standard template and go from there.

Production build 0.71.5 2024