EntityTypeBundleInfo returns wrong language

Created on 8 May 2024, 8 months ago

Problem/Motivation

EntityTypeBundleInfo returns wrong language version when called before language negotiation is finished.

Turns out it still has a static cache property (not aware of cache contexts like language or cache tag invalidation).

Steps to reproduce

After quire some debugging it boils down to this minimal test-code:
- Set current interface language to en
- Call EntityTypeBundleInfo::getAllBundleInfo
- Set current interface language to de
- Call EntityTypeBundleInfo::getAllBundleInfo
- Expected: Get de translation.
- Actual: Get en translation.

This happened on my installation in this scenario:
- Have an entity (commerce_store) with some paragraph fields
- `drush cr`
- Create (not edit) commerce store (in my case in group context)
- Expected: See Paragraph button "[DE bundle label] hinzufügen"
- Actual: See Paragraph button "[EN bundle label] hinzufügen"
- FTR: Also, clicking that paragraph button adds a *different* paragraph (that with the last button) to the form. (Which looks like a separate form builder bug.)

Proposed resolution

Replace static cache with memory cache backend (like everywhere else).

Remaining tasks

- Code, review, commit.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Entity 

Last updated about 16 hours ago

Created by

🇩🇪Germany geek-merlin Freiburg, Germany

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

Merge Requests

Comments & Activities

  • Issue created by @geek-merlin
  • Status changed to Needs work 8 months ago
  • 🇩🇪Germany geek-merlin Freiburg, Germany

    Added MR with one commit that adds a language key to the static cache.

    It fixes the issue for me and proves that this low-level approach fixes the described behavioral issue.

    The proper fix is of course a memory cache backend that handles invalidation too.

  • Pipeline finished with Success
    8 months ago
    Total: 609s
    #167716
Production build 0.71.5 2024