EntityReferenceFieldItemList::referencedEntities might not return up-to-date entity objects

Created on 11 November 2016, about 8 years ago
Updated 8 April 2023, over 1 year ago

Problem/Motivation

EntityReferenceFieldItemList::referencedEntities in its current implementation will collect all the target ids from the field items and then collect the referenced entity objects by calling loadMultiple, but this is faulty in the following use cases:

  1. An entity cloned object has been set on some of the field items -> load will not return this one but a different one.
  2. resetCache is called after the entity objects have been initialized on some of the field items.

Proposed resolution

EntityReferenceFieldItemList::referencedEntities should first collect the entities which are already set on the field items and load the remaining ones through loadMultiple.

Remaining tasks

  • Add test coverage
  • Review

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Needs work

Version

10.1 ✨

Component
EntityΒ  β†’

Last updated 26 minutes ago

Created by

πŸ‡©πŸ‡ͺGermany hchonov πŸ‡ͺπŸ‡ΊπŸ‡©πŸ‡ͺπŸ‡§πŸ‡¬

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

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