Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293174

EntityReferenceFieldItemList::referencedEntities relies on the static cache to not lose data

$
0
0

Problem/Motivation

This is a data loss bug in the entity system but it's hard enough to hit not to be critical. Let's have this setup: $parent->reference->entity = $child where reference is an entity reference field and $child is stored already in the database.

  1. change $child in any way
  2. call the resetCache method on the entity storage of $child
  3. call $parent->reference->referencedEntities(). This will return $child as it is in the database instead of the changed state.

Proposed resolution

Add EntityReferenceItem::hasEntity much like EntityReferenceItem::hasNewEntity and use the entity if it already is there instead of loading. This will also be a performance boost (tiny in most cases but still).

Remaining tasks

Approve, code, review, code, review, code, review etc until satisfied, commit, rejoice :D

User interface changes

None.

API changes

A new method on EntityReferenceItem.

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 293174

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>