Static cache in FallbackController service does not consider langcode

Created on 24 August 2023, about 1 year ago

Problem/Motivation

The FallbackController service uses a static cache in the $entityBundleCandidates property to remember calculated language fallback chains in the method getEntityFallbackCandidates(). This is fine when handling normal requests, but may fail when running batch processes, where the "current language" language can change. Then a faulty fallback chain might be cached for a entity type and bundle combination.

Steps to reproduce

No explicit steps to reproduce, yet. This is a presumable scenario:

1.) Configure multiple languages with different fallback chains.
2.) Add nodes with multiple translations.
3.) Employ batch process with sub-requests in different language contexts, e.g., search indexing of these nodes in different languages.
4.) Use rendered_item as a search index field. This uses the view builder and also renders the indexed entities.
5.) The indexed content may display faulty translations although the translation exists in Drupal.

Proposed resolution

Add the language code to the cache ID. Then multiple language fallback chains can be considered.

Remaining tasks

Review changes. Maybe consider test coverage, but that is probably outside of the scope of this issue.

🐛 Bug report
Status

Closed: duplicate

Version

1.0

Component

Code

Created by

🇩🇪Germany simonbaese Berlin

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

Comments & Activities

Production build 0.71.5 2024