Using drupal_block() to render the language block causes cache issues

Created on 6 June 2025, about 1 month ago

Problem/Motivation

When using drupal_block() to render the Drupal core language block, some caching issues are caused. At least, processed text formats re-process on every page load.

Steps to reproduce

Create a content type with a formatted text field.
Use a text format that uses some input filters, like the HTML tag filter.
Create a new node of this type and view it.
Use logging or debugging to confirm that the input filter only processes on the first load, and thereafter it is cached.
Create a custom template in your theme for this content type.
Enable twig_tweak and the language module.
In the custom template, somewhere add: {{ drupal_block('language_block:language_interface', wrapper=false) }}
View that same node again, refreshing multiple times
Observe that every time you refresh, the input filter processes the text

Proposed resolution

There is a lot of discussion related to this in: https://www.drupal.org/project/drupal/issues/2232375 πŸ“Œ Make language switcher block cacheable Postponed

I don't know enough to make any recommendations, and was advised in that issue to create this issue. In the meantime our plan is to use the regular block layout system instead of twig_tweak, for the language block.

πŸ› Bug report
Status

Active

Version

3.4

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States brockfanning

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

Comments & Activities

Production build 0.71.5 2024