- Issue created by @pbabin
When using Smart Date with JSON:API (e.g. via Entity Share), SmartDateNormalizer::denormalize() returns the full Smart Date field structure during per-property denormalization.
FieldItemNormalizer expects each property (value, end_value, duration, etc.) to be denormalized independently, but SmartDateNormalizer returns an array of all properties, causing data nesting and unexpected structures.
Example of the resulting $data_internal from FieldItemNormalizer:
array (
'value' =>
array (
'value' => 1760029200,
'end_value' => NULL,
'duration' => NULL,
'rrule' => NULL,
'rrule_index' => NULL,
'timezone' => NULL,
),
'end_value' =>
array (
'value' => 1760032800,
'end_value' => NULL,
'duration' => NULL,
'rrule' => NULL,
'rrule_index' => NULL,
'timezone' => NULL,
),
'duration' => 60,
'rrule' => NULL,
'rrule_index' => NULL,
'timezone' => '',
)
Cause
FieldItemNormalizer calls denormalizers on each property individually.
SmartDateNormalizer::denormalize() assumes it always receives the full SmartDate object and builds an array of all properties.
This mismatch leads to nested/duplicated data.
Proposed Solution
Update SmartDateNormalizer::denormalize() to detect when it is receiving:
A scalar/NULL value (per-property denormalization) β delegate to TimestampNormalizer.
An array/object (whole SmartDate item) β build and return the full property array.
Will have a merge request in soon.
Full Disclosure
I originally reported this at the Entity Share queue - you can see a full write up there π Nested array values incorrectly processed with smart_date values Active . Assistance with this write up care of ChatGPT.
Active
4.2
Code