By berdir on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
12.0.x
Introduced in version:
12.0.0
Issue links:
Description:
Entity reference fields (including inheriting types like Entity Reference Revisions and Dynamic Entity Reference) now used property hooks to set and get their entity and target_id field properties.
This makes these properties more accessible to IDE's and other tools and removes the need for complex workarounds around PHP bugs with fibers and magic methods (see #3565937: Workaround PHP bug with fibers and __get()).
As a result, it is no longer possible assigned typed data value objects to these properties directly.
// Still works, nothing changes.
$entity->get('field_reference')->entity = $entity->get('field_other_reference')->entity;
$entity->get('field_reference')->first()->entity = $entity->get('field_other_reference')->entity;
$entity->get('field_reference')->first()->set('entity', $entity->get('field_other_reference')->entity);
// This no longer works:
$entity->get('field_reference')->entity = $entity->get('field_other_reference')->first()->get('entity');
$entity->get('field_reference')->first()->entity = $entity->get('field_other_reference')->first()->get('entity');
// This never worked:
$entity->get('field_reference')->first()->set('entity', $entity->get('field_other_reference')->first()->get('entity'));
Impacts:
Module developers