-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Denormalizer tries to process null attributes even though they are nullable #27384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Comments
Hello, |
ogizanagi
added a commit
that referenced
this issue
May 30, 2018
…es on nullable properties (ogizanagi) This PR was merged into the 3.4 branch. Discussion ---------- [Serializer] Fix serializer tries to denormalize null values on nullable properties | Q | A | ------------- | --- | Branch? | 3.4 <!-- see below --> | Bug fix? | yes | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #27384 <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | N/A Commits ------- ca31488 [Serializer] Fix serializer tries to denormalize null values on nullable properties
Hi, I still have this happening when denormalizing an array to object. The property is not in the constructor, but is defined as private ?string and the comment also typed to string|null. I'm writing from my phone, but I can post a code example if further explanation is required. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Symfony version(s) affected: 4
Description
Symfony tries to denormalize nested models null attributes even though they are nullable. It occurs when those models use constructor methods.
How to reproduce
When trying to deserialize a Model (with a SubModel containing a null
$date
), aNotNormalizableValueException
is thrown, with the following message :The data is either an empty string or null, you should pass a string that can be parsed with the passed format or a valid DateTime string.
Possible Solution
As a workaround, use setters instead of constructors.
The problem seems to lie in
AbstractNormalizer
, ininstantiateObject
method : it tries to denormalize the constructor parameter, even if its value is null.The text was updated successfully, but these errors were encountered: