diff -u b/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php --- b/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -505,16 +505,16 @@ // Cover the case where an entity reference field might reference // different entity types at once. $entity_type_id = $entity->getEntityTypeId(); - $current_entity_storage = isset($entity_storages[$entity_type_id]) ? $entity_storages[$entity_type_id] : $this->entityTypeManager()->getStorage($entity_type_id); + $entity_storages[$entity_type_id] = isset($entity_storages[$entity_type_id]) ? $entity_storages[$entity_type_id] : $this->entityTypeManager()->getStorage($entity_type_id); $consider_static_cache = $entity->getEntityType()->isRevisionable() && $entity instanceof RevisionableInterface && $entity->isDefaultRevision() || !($entity instanceof RevisionableInterface); if (!$consider_static_cache) { continue; } - elseif ($static_cache_entities = $current_entity_storage->getFromStaticCache([$entity->id()])) { + elseif ($static_cache_entities = $entity_storages[$entity_type_id]->getFromStaticCache([$entity->id()])) { $value['entity'] = $static_cache_entities[$entity->id()]; } else { - $current_entity_storage->setStaticCache([$entity->id() => $entity]); + $entity_storages[$entity_type_id]->setStaticCache([$entity->id() => $entity]); } } } diff -u b/core/modules/field/field.install b/core/modules/field/field.install --- b/core/modules/field/field.install +++ b/core/modules/field/field.install @@ -6,6 +6,7 @@ */ use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem; +use Drupal\file\Plugin\Field\FieldType\FileItem; /** * Removes the stale 'target_bundle' storage setting on entity_reference fields. @@ -106,10 +107,15 @@ } /** + * @addtogroup updates-8.3.x + * @{ + */ + +/** * Populate the new 'serialize_embedded_entities' setting for entity reference * fields. */ -function field_update_8004() { +function field_update_8300() { $config = \Drupal::configFactory(); /** @var \Drupal\Core\Field\FieldTypePluginManager $field_type_manager */ $field_type_manager = \Drupal::service('plugin.manager.field.field_type'); @@ -127,7 +133,11 @@ - $settings['serialize_embedded_entities'] = FALSE; + $settings['serialize_embedded_entities'] = is_subclass_of($class, FileItem::class) ? TRUE : FALSE; } $field->set('settings', $settings)->save(TRUE); } } } + +/** + * @} End of "addtogroup updates-8.3.x". + */ only in patch2: unchanged: --- a/core/modules/file/config/schema/file.schema.yml +++ b/core/modules/file/config/schema/file.schema.yml @@ -43,6 +43,9 @@ field.value.file: base_file_field_field_settings: type: mapping mapping: + serialize_embedded_entities: + type: boolean + label: 'Serialize entity references together with the parent entity' handler: type: string label: 'Reference method' only in patch2: unchanged: --- a/core/modules/file/src/Plugin/Field/FieldType/FileItem.php +++ b/core/modules/file/src/Plugin/Field/FieldType/FileItem.php @@ -49,6 +49,7 @@ public static function defaultFieldSettings() { 'file_directory' => '[date:custom:Y]-[date:custom:m]', 'max_filesize' => '', 'description_field' => 0, + 'serialize_embedded_entities' => TRUE, ) + parent::defaultFieldSettings(); } only in patch2: unchanged: --- a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php +++ b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php @@ -3,10 +3,10 @@ namespace Drupal\file\Plugin\Field\FieldWidget; use Drupal\Component\Utility\NestedArray; +use Drupal\Core\Field\EntityReferenceInlineWidgetBase; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; -use Drupal\Core\Field\WidgetBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Render\Element; @@ -27,7 +27,7 @@ * } * ) */ -class FileWidget extends WidgetBase implements ContainerFactoryPluginInterface { +class FileWidget extends EntityReferenceInlineWidgetBase implements ContainerFactoryPluginInterface { /** * {@inheritdoc} only in patch2: unchanged: --- a/core/modules/forum/config/optional/field.field.node.forum.taxonomy_forums.yml +++ b/core/modules/forum/config/optional/field.field.node.forum.taxonomy_forums.yml @@ -16,6 +16,7 @@ translatable: true default_value: { } default_value_callback: '' settings: + serialize_embedded_entities: false handler: 'default:taxonomy_term' handler_settings: target_bundles: only in patch2: unchanged: --- a/core/profiles/standard/config/install/field.field.node.article.field_image.yml +++ b/core/profiles/standard/config/install/field.field.node.article.field_image.yml @@ -32,6 +32,7 @@ settings: title: '' width: null height: null + serialize_embedded_entities: true handler: 'default:file' handler_settings: { } field_type: image only in patch2: unchanged: --- a/core/profiles/standard/config/install/field.field.node.article.field_tags.yml +++ b/core/profiles/standard/config/install/field.field.node.article.field_tags.yml @@ -16,6 +16,7 @@ translatable: true default_value: { } default_value_callback: '' settings: + serialize_embedded_entities: false handler: 'default:taxonomy_term' handler_settings: target_bundles: only in patch2: unchanged: --- a/core/profiles/standard/config/install/field.field.user.user.user_picture.yml +++ b/core/profiles/standard/config/install/field.field.user.user.user_picture.yml @@ -32,6 +32,7 @@ settings: height: null alt_field_required: false title_field_required: false + serialize_embedded_entities: true handler: 'default:file' handler_settings: { } field_type: image