Closed (fixed)
Project:
Smart Date
Version:
4.2.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
20 May 2026 at 20:45 UTC
Updated:
3 Jul 2026 at 14:20 UTC
Jump to comment: Most recent
PHP Fatal error: Declaration of Drupal\smart_date\Normalizer\SmartDateItemNormalizer::normalize($object, $format = null, array $context = []): ArrayObject|array|string|int|float|bool|null must be compatible with Drupal\serialization\Normalizer\TimestampItemNormalizer::normalize($object, $format = null, array $context = []): array in /var/www/html/web/modules/contrib/smart_date/src/Normalizer/SmartDateItemNormalizer.php on line 30
Upgrade Drupal to 11.4.x-dev, witness the error.
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
ishani patel commentedHello,
I've raised MR for this.
Kindly check and review it.
Thank you!
Comment #5
ltrain@ishani The MR works perfectly. Thanks!
Comment #6
ltrainComment #7
dalinComment #9
mandclu commentedI'm concerned that this change will break any site running Drupal <11.4, which would be its own critical issue.
I don't love the idea of having to have a new version that would only support Drupal 11.4+. Are there alternatives we could consider?
Comment #10
dalin@mandclu
With the help of AI
> The good news is that return types in PHP are covariant: an overriding/implementing method may declare a narrower return type than the interface it implements, but not a wider one. Since array is one of the members of the union array|string|int|float|bool|\ArrayObject|null, declaring your method as returning plain array is a valid covariant override of an interface that declares the wider union. So this single declaration satisfies both the new interface (: array) and the old one (: array|string|int|float|bool|\ArrayObject|NULL):
Comment #11
mandclu commentedThanks for that @dalin. I was able to load a patched version of Smart Date in Drupal 11.3 and didn't see any errors. That said, I didn't realize at the time that there is actually more required to trigger the error.
Also leaning into our robot overlords for advice:
I was ultimately able to reproduce the error by enabling JSON:API (and not before). Subsequently I was able to reproduce the error on the command line with (using a node with a Smart Date field):
ddev drush php-eval "\Drupal::service('serializer')->normalize(\Drupal\node\Entity\Node::load(1), 'application/json');"
This allowed me to confirm that the provided patch does, in fact resolve the fatal error. I feel like I should give contribution credit to Claude as well :P
Comment #13
mandclu commentedThanks for the work here. I will roll a new release with this fix.