Deep references lose langcode during formatting

Created on 25 July 2020, over 4 years ago
Updated 8 August 2020, over 4 years ago

Problem/Motivation

  1. Entity A has a translation in language L. It refers entity B and the reference field is formatted using entity_reference_entity_view
  2. Entity B does not have a translation in language L. It refers entity C and the reference field is formatted using entity_reference_entity_view
  3. Entity C has a translation in language L.

In this case, when viewing Entity A in language L, Entity C will not be in the correct language.

The root cause is EntityReferenceEntityFormatter::viewElements() rendering the referred entity in the parent entity langcode. But the parent entity might be in a fallback langcode.

Steps to reproduce

  1. Have German set up besides and English.
  2. Add a node reference field to a node type,
  3. Set the formatter to "Rendered entity"
  4. Create a node with German and English translations.
  5. Create another English node, set the reference field to point to the previous node. Do not translate this one.
  6. Create another node, set the reference field to point to the previous node. Translate this one to German.

Viewing the last node in German will render the first node in English.

Proposed resolution

Pass the langcode down the chain. The patch is much smaller than this issue summary :) (The test isn't.)

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
EntityΒ  β†’

Last updated about 17 hours ago

Created by

πŸ‡¨πŸ‡¦Canada Charlie ChX Negyesi 🍁Canada

Live updates comments and jobs are added and updated live.
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.

Production build 0.71.5 2024