Problem/Motivation
In \Drupal\Component\Datetime\DateTimePlus::checkArray() we do
if (@checkdate($array['month'], $array['day'], $array['year'])) {
$valid_date = TRUE;
}
The $array['month'], $array['day'], $array['year'] values are not guaranteed to be integers and they should be. In PHP8 this causes test failures.
This error is produced when running Drupal\Tests\datetime\Functional\DateTimeFieldTest::testDatelistWidget see https://dispatcher.drupalci.org/job/drupal_patches/51890/testReport/juni...
Proposed resolution
Casting each value to an integer works but is it the best fix?
This issue should also be backported to 8.9.x so that Drupal 8 can be PHP 8.0 compatible.
Remaining tasks
User interface changes
N/a
API changes
N/a
Data model changes
N/a
Release notes snippet
N/a
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 3156878-4.patch | 3.56 KB | alexpott |
| #4 | 3156878-4.test-only.patch | 2.49 KB | alexpott |
| #4 | 2-4-interdiff.txt | 3.57 KB | alexpott |
Comments
Comment #2
alexpottThis is a bug on PHP 8 :)
Comment #3
andypostThis change sounds strange, tested on alpha 3 locally
It means that wrong data passed to function in tests, so setting NW to get which tests are broken without this change
Comment #4
alexpottThe important thing about the code in HEAD is the suppression of warnings - i.e the @ sign. The problem we have is https://3v4l.org/Slqii
Sometimes we're passing empty strings into checkdate.
So we can definitely improve this - compare https://3v4l.org/HBXvM vs https://3v4l.org/poPFV vs https://3v4l.org/p6SKR
Comment #5
andypostAs empty value allows to skip function already ++ to patch approach!
I'd say it a bit improvement as now invalid dates could be caught
Comment #7
andypostTest known as randomly failed
Comment #11
gábor hojtsyThanks! Committed and cherry-picked.
Comment #12
andypostThank you!