Referring the same entity multiple times breaks _referringItem

Created on 22 November 2024, 2 months ago

Problem/Motivation

EntityReferenceFormatterBase::getEntitiesToView() sets $entity->_referringItem but if the same entity is referred multiple times then the value gets overridden.

Steps to reproduce

Refer the same file twice, add something to $item->_attributes in hook_entity_prepare_view to both of the referring items, observe how GenericFileFormatter makes a total hash of it: the first file link will get the attributes of the second and the second will get nothing.

Proposed resolution

Perhaps getEntitiesToView should clone entities ? Add $entity = clone $entity; before $entity->_referringItem = $items[$delta]; ?

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Active

Version

11.1 πŸ”₯

Component

entity system

Created by

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

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024