-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form][Validator] Fix checking result of DateTime::getLastErrors #47428
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
Conversation
f7da2e5
to
c2eb637
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like (at least) the DateTimeValidator
needs some more changes
Access to |
On 30 August 2022 11:25:46 BST, Nicolas Grekas ***@***.***> wrote:
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
Spotted by our CI on PHP 8.2
This returns an array on PHP < 8.2 and `false` on 8.2:
```php
DateTime::createFromFormat('Y', '2022');
var_dump(DateTime::getLastErrors());
```
/cc @derickr FYI as this might also be considered as a BC break on PHP 8.2
You can view, comment on, or merge this pull request online at:
#47428
-- Commit Summary --
* Fix checking result of DateTime::getLastErrors
-- File Changes --
M src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php (2)
M src/Symfony/Component/Validator/Constraints/DateTimeValidator.php (2)
-- Patch Links --
https://github.com/symfony/symfony/pull/47428.patch
https://github.com/symfony/symfony/pull/47428.diff
This is a bug fix as the new 8.2 behaviour is how it has been documented for over a decade. I didn't merge it to 8.0 and 8.1 because it does change BC.
|
Well, I would say that code is a lot more likely to expect the behavior that exists since a decade than the documented code that was never implemented until now. |
yup, fixed |
c2eb637
to
39cd15b
Compare
I just stumbled upon this bug in my project, wrote the pr, unit test and was getting ready to submit and then checked my branch was up to date and it wasn't, so checked here and BANG 🎉 its already fixed 5 days ago... you guys are awesome! |
This PR was squashed before being merged into the 6.1.x-dev branch. Discussion ---------- PHP 8.2 Compatibility DateTime::getLastErrors DateTime::getLastErrors() is documented as returning `array|false` https://www.php.net/manual/en/datetime.getlasterrors.php As discussed here symfony/symfony#47428 (comment) `@derickr` quoted as saying "This is a bug fix as the new 8.2 behaviour is how it has been documented for over a decade." Commits ------- 00f08ea PHP 8.2 Compatibility DateTime::getLastErrors
Spotted by our CI on PHP 8.2
This returns an array on PHP < 8.2 and
false
on 8.2:/cc @derickr FYI as this might also be considered as a BC break on PHP 8.2