diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index 3cd9df2..e1ec846 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -158,6 +158,9 @@ /** * Whether to serialize the complete entity structure. * + * If set to TRUE when the entity is being serialized a deep serialization + * will be performed and the flag will be automatically set back to FALSE. + * * @var bool */ protected $deepSerialization = FALSE; @@ -470,16 +473,6 @@ public function __sleep() { /** * {@inheritdoc} */ - public function deepSerialize() { - // When running a deep serialization the flag "deepSerialization" has to be - // set in order to serialize referenced entities as well. - $this->deepSerialization = TRUE; - return serialize($this); - } - - /** - * {@inheritdoc} - */ public function setDeepSerialization($deep_serialization = TRUE) { $this->deepSerialization = $deep_serialization; } diff --git a/core/lib/Drupal/Core/Entity/FieldableEntityInterface.php b/core/lib/Drupal/Core/Entity/FieldableEntityInterface.php index 0de625a..e6ed455 100644 --- a/core/lib/Drupal/Core/Entity/FieldableEntityInterface.php +++ b/core/lib/Drupal/Core/Entity/FieldableEntityInterface.php @@ -237,14 +237,6 @@ public function isValidationRequired(); public function setValidationRequired($required); /** - * Returns a deeply serialized entity. - * - * @return string - * The deeply serialized entity. - */ - public function deepSerialize(); - - /** * Flags the entity for deep serialization. * * After calling this method and serializing the entity e.g. diff --git a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntitySerializationTest.php b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntitySerializationTest.php index 7e2a442..4feee94 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntitySerializationTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntitySerializationTest.php @@ -108,8 +108,10 @@ protected function doTestSerialization($deep_serialization) { $entity_level_zero->$field_name->entity->name = 'entity level one'; $entity_level_zero->$field_name->entity->$field_name->entity->name = 'entity level two'; - $serialized_entity = $deep_serialization ? $entity_level_zero->deepSerialize() : serialize($entity_level_zero); - $entity_level_zero = unserialize($serialized_entity); + if ($deep_serialization) { + $entity_level_zero->setDeepSerialization(TRUE); + } + $entity_level_zero = unserialize(serialize($entity_level_zero)); // If regular serialization is tested then the changes on the referenced // entities should be lost, but kept if deep serialization is tested.