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 @@ -149,6 +149,13 @@ protected $validationRequired = FALSE; /** + * Whether to serialize the initialized fields when serializing the entity. + * + * @var bool + */ + public $serializeFields = FALSE; + + /** * {@inheritdoc} */ public function __construct(array $values, $entity_type, $bundle = FALSE, $translations = array()) { @@ -416,10 +423,8 @@ $this->values[$name][$langcode] = $field->getValue(); } } - // Serialize fields only if requested so. - if (empty($this->serializeFields)) { - $this->fields = array(); - } + // Serialize initialized fields only if requested so. + $this->fields = $this->serializeFields ? $this->fields : []; $this->fieldDefinitions = NULL; $this->languages = NULL; $this->clearTranslationCache(); @@ -431,7 +436,7 @@ * {@inheritdoc} */ public function __wakeup() { - unset($this->serializeFields); + $this->serializeFields = FALSE; parent::__wakeup(); }