referencedEntities() causes data loss

Created on 5 December 2019, over 4 years ago
Updated 27 January 2024, 5 months ago

Problem/Motivation

EntityReferenceRevisionsFieldItemList::referencedEntities loads the referenced entities by revision id from the database instead of using the existing entities on the reference item. This leads to potential data loss if the referenced entity has a change compared to the database.

Proposed resolution

This was implemented based on EntityReferenceFieldItemList::referencedEntities but there are two fundamental differences a) there's no static cache for revision list loads which means the object on the entity property will differ from what load returns -- for plain entity references the load will return the handle of an object in the memory cache b) there's no point because there's no loadMultiple for revisions. The whole method should be collapsed into

foreach ($this->list as $delta => $item) {
  if ($item->entity) {
    $target_entities[$delta] = $item->entity;
  }
}
return $target_entities;

and be done. This will actually be faster in many cases because the EntityReferenceRevisions / entity_revision_reference data type plugin optimizes getTarget().

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

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.69.0 2024