8000 bug #40598 [Form] error if the input string couldn't be parsed as a d… · symfony/symfony@5666a45 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5666a45

Browse files
committed
bug #40598 [Form] error if the input string couldn't be parsed as a date (xabbuh)
This PR was merged into the 4.4 branch. Discussion ---------- [Form] error if the input string couldn't be parsed as a date | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #40597 | License | MIT | Doc PR | When the Intl polyfill is used instead of the PHP intl extension, the intl_get_error_code() function always returns 0 no matter if the input string could be parsed. Commits ------- 5ce5300 error if the input string couldn't be parsed as a date
2 parents 9889c49 + 5ce5300 commit 5666a45

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ public function reverseTransform($value)
130130
} elseif ($timestamp > 253402214400) {
131131
// This timestamp represents UTC midnight of 9999-12-31 to prevent 5+ digit years
132132
throw new TransformationFailedException('Years beyond 9999 are not supported.');
133+
} elseif (false === $timestamp) {
134+
// the value couldn't be parsed but the Intl extension didn't report an error code, this
135+
// could be the case when the Intl polyfill is used which always returns 0 as the error code
136+
throw new TransformationFailedException(sprintf('"%s" could not be parsed as a date.', $value));
133137
}
134138

135139
try {

0 commit comments

Comments
 (0)
0