reverted: --- b/core/modules/field/lib/Drupal/field/Entity/Field.php +++ a/core/modules/field/lib/Drupal/field/Entity/Field.php @@ -710,16 +710,19 @@ } } + /** + * {@inheritdoc} + */ + public function serialize() { + // Only store the definition, not external objects or derived data. + return serialize($this->getExportProperties()); - public function __sleep() { - return array_intersect(array_keys($this->getExportProperties()), array_keys(get_object_vars($this))); } + /** + * {@inheritdoc} + */ + public function unserialize($serialized) { + $this->__construct(unserialize($serialized)); - public function __wakeup() { - // @todo array_filter() not great... - $new_obj = new static(array_filter(get_object_vars($this))); - foreach (get_object_vars($new_obj) as $key => $value) { - $this->{$key} = $value; - } } /** reverted: --- b/core/modules/field/lib/Drupal/field/Entity/FieldInstance.php +++ a/core/modules/field/lib/Drupal/field/Entity/FieldInstance.php @@ -643,16 +643,19 @@ unset($this->{$offset}); } + /** + * {@inheritdoc} + */ + public function serialize() { + // Only store the definition, not external objects or derived data. + return serialize($this->getExportProperties()); - public function __sleep() { - return array_intersect(array_keys($this->getExportProperties()), array_keys(get_object_vars($this))); } + /** + * {@inheritdoc} + */ + public function unserialize($serialized) { + $this->__construct(unserialize($serialized)); - public function __wakeup() { - // @todo array_filter() not great... - $new_obj = new static(array_filter(get_object_vars($this))); - foreach (get_object_vars($new_obj) as $key => $value) { - $this->{$key} = $value; - } } } reverted: --- b/core/modules/field/lib/Drupal/field/FieldInstanceInterface.php +++ a/core/modules/field/lib/Drupal/field/FieldInstanceInterface.php @@ -13,7 +13,7 @@ /** * Provides an interface defining a field instance entity. */ +interface FieldInstanceInterface extends ConfigEntityInterface, FieldDefinitionInterface, \ArrayAccess, \Serializable { -interface FieldInstanceInterface extends ConfigEntityInterface, FieldDefinitionInterface, \ArrayAccess { /** * Returns the field entity for this instance. reverted: --- b/core/modules/field/lib/Drupal/field/FieldInterface.php +++ a/core/modules/field/lib/Drupal/field/FieldInterface.php @@ -13,7 +13,7 @@ /** * Provides an interface defining a field entity. */ +interface FieldInterface extends ConfigEntityInterface, FieldDefinitionInterface, \ArrayAccess, \Serializable { -interface FieldInterface extends ConfigEntityInterface, FieldDefinitionInterface, \ArrayAccess { /** * Returns the field schema.