diff --git a/core/lib/Drupal/Core/Config/Schema/Element.php b/core/lib/Drupal/Core/Config/Schema/Element.php index 4993de8..0bd390c 100644 --- a/core/lib/Drupal/Core/Config/Schema/Element.php +++ b/core/lib/Drupal/Core/Config/Schema/Element.php @@ -23,13 +23,6 @@ protected $typedConfig; /** - * The configuration value. - * - * @var mixed - */ - protected $value; - - /** * Create typed config object. */ protected function parseElement($key, $data, $definition) { diff --git a/core/lib/Drupal/Core/Field/FieldItemBase.php b/core/lib/Drupal/Core/Field/FieldItemBase.php index b411b88..37b2dc4 100644 --- a/core/lib/Drupal/Core/Field/FieldItemBase.php +++ b/core/lib/Drupal/Core/Field/FieldItemBase.php @@ -51,6 +51,17 @@ public static function mainPropertyName() { */ public function __construct(DataDefinitionInterface $definition, $name = NULL, TypedDataInterface $parent = NULL) { parent::__construct($definition, $name, $parent); + // Data types such as Integer or String use a simple value property to + // manage their value, which is why TypedData::getValue() uses that property + // for convencience of those data types. By declaring it as a member + // variable of the TypedData class, however, PHP sets a NULL value to it + // upon instantiation. This breaks field types which have a 'value' property + // as by inheriting from this class they inherit from TypedData as well and, + // thus, $field_item->value returns NULL directly instead of asking + // FieldItemBase::__get() for the proper value stored in + // $field_item->values['value']. Hence, we unset the NULL value. + unset($this->value); + // Initialize computed properties by default, such that they get cloned // with the whole item. foreach ($this->definition->getPropertyDefinitions() as $name => $definition) { diff --git a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Any.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Any.php index e53b3ae..eea3ab3 100644 --- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Any.php +++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Any.php @@ -21,12 +21,4 @@ * label = @Translation("Any data") * ) */ -class Any extends TypedData { - - /** - * The data value. - * - * @var mixed - */ - protected $value; -} +class Any extends TypedData {} diff --git a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Timestamp.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Timestamp.php index 800344b..6972635 100644 --- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Timestamp.php +++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Timestamp.php @@ -21,13 +21,6 @@ class Timestamp extends Integer implements DateTimeInterface { /** - * The data value as a UNIX timestamp. - * - * @var integer - */ - protected $value; - - /** * {@inheritdoc} */ public function getDateTime() { diff --git a/core/lib/Drupal/Core/TypedData/PrimitiveBase.php b/core/lib/Drupal/Core/TypedData/PrimitiveBase.php index dae6dbe..8a79829 100644 --- a/core/lib/Drupal/Core/TypedData/PrimitiveBase.php +++ b/core/lib/Drupal/Core/TypedData/PrimitiveBase.php @@ -13,13 +13,6 @@ abstract class PrimitiveBase extends TypedData implements PrimitiveInterface { /** - * The data value. - * - * @var mixed - */ - protected $value; - - /** * {@inheritdoc} */ public function getValue() { diff --git a/core/lib/Drupal/Core/TypedData/TypedData.php b/core/lib/Drupal/Core/TypedData/TypedData.php index 3216d21..bd7caa7 100644 --- a/core/lib/Drupal/Core/TypedData/TypedData.php +++ b/core/lib/Drupal/Core/TypedData/TypedData.php @@ -44,6 +44,13 @@ protected $parent; /** + * The configuration value. + * + * @var mixed + */ + protected $value; + + /** * {@inheritdoc} */ public static function createInstance($definition, $name = NULL, TraversableTypedDataInterface $parent = NULL) {