Needs work
Project:
Drupal core
Version:
main
Component:
entity system
Priority:
Major
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
4 Mar 2019 at 07:20 UTC
Updated:
6 Mar 2019 at 10:43 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
amateescu commentedBringing over the patch from #2942907-116: Entity system does not provide an API for retrieving an entity variant that is safe for editing.
Comment #3
amateescu commentedThe parent issue was committed, we can resume work here :)
Comment #5
amateescu commentedRerolled.
Comment #7
johnwebdev commentedWhy is a static cache needed to ensure identity right now?
Comment #8
amateescu commentedNot sure what you mean by "right now", and this is about equality, not identity :)
The reason why I think we should perform a strict equality check against a static cache is because of the way PHP compares objects (http://php.net/manual/en/language.oop5.object-comparison.php), and I'm worried that a loose equality check would be very expensive for our entity objects, which have *a lot* of properties and some of them might even lead to infinite recursion.
However, on a second thought, it may be better to introduce an
EntityInterface::equals()method, just like we have for field item lists, because at least we can optimize that one as much as possible.Comment #9
johnwebdev commentedSorry, I misinterpreted your @todo, and I simply meant why we didn't compare the arrays ===, (which is called identity, http://php.net/manual/en/language.operators.array.php)
Do we really need to check all the values to know if it is active though?
The ::equals sounds like a good idea :)