Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Serializer] Trigger deprecation when could not parse date with default format #58966

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

Open
wants to merge 7 commits into
base: 7.4
Choose a base branch
Loading
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer…
….php

Co-authored-by: Mathias Arlaud <mathias.arlaud@gmail.com>
  • Loading branch information
alexndlm and mtarld committed Jan 13, 2025
commit fc42ccaba3778e4ecfbc1395838e38dfcc035f0c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function denormalize(mixed $data, string $type, ?string $format = null, a
return $object;
}

trigger_deprecation('symfony/serializer', '7.3', \sprintf('NotNormalizableValueException will be thrown when date could not be parsed using the default format "%s".', $defaultDateTimeFormat));
trigger_deprecation('symfony/serializer', '7.3', \sprintf('A "%s" will be thrown when a date could not be parsed using the default format "%s".', NotNormalizableValueException::class, $defaultDateTimeFormat));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should trigger a deprecation here only if the fallback manages to instantiate it. The case where the fallback throws an exception (already turned into a NotNormalizableValueException below) should not trigger a deprecation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand, in 8.0, the fallback should be removed, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. And that's my point: if the fallback also fails, you already have the same behavior than what would happen in 8.0 and we should not trigger a deprecation in that case as the behavior will not change. Try submitting foobar as value to reproduce that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have rechecked and now realise that fallback should not be removed in 8.0. Fallback should still be used when datetime_format is set to null.

}

return new $type($data, $timezone);
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.