- Merge request !1976Issue #3269890: #date_year_range is not validated server-side โ (Open) created by prudloff
- ๐บ๐ธUnited States smustgrave
This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request โ as a guide.
The MR will need to be updated to 9.5.x or 10.1.x
also will require a test case to show the issue.
- Status changed to Needs review
about 2 months ago 1:46pm 8 March 2025 - ๐ซ๐ทFrance prudloff Lille
I rebased and added a test.
Looking at the code, the logic may be located better in a place where it makes $date->hasErrors() (the line above the code changes) fail, but I'm not familiar enough with how these kinds of PHP classes should be coded to claim your code changes need to be reworked, so I'm leaving the issue state as is.
DateTimePlus::hasErrors() checks if the date is a valid date but it has no notion of allowed values.
- ๐บ๐ธUnited States smustgrave
1) Drupal\KernelTests\Core\Datetime\DatetimeElementFormTest::testRangeValidate Failed asserting that null matches expected 'The range_datetime_element date is invalid. Date should be in the 1850-3000 year range.'. /builds/issue/drupal-3269890/core/tests/Drupal/KernelTests/Core/Datetime/DatetimeElementFormTest.php:224 FAILURES! Tests: 5, Assertions: 11, Failures: 1.
Shows test coverage so removing the tag for tests, also the coverage being added looks great and in depth.
Believe all feedback for this one has been addressed.
- First commit to issue fork.
- ๐ฎ๐ณIndia shalini_jha
I have rebased this MR and resolved the merge conflicts. During the rebase, I noticed that some new behavior was introduced, so to ensure everything continues to work as expected, I re-ran the range test locally.
While debugging, I found that the test was failing in the third scenario where the datetime value falls within the defined range. Due to the newly introduced behavior Here โจ Datetime fields should utilise #required_error Needs review , the form state now includes additional errors such as datetime_required_error and datetime_no_required_error.
To address this, I updated the third scenarioโs assertion to only check that range_datetime_element is not present in the form state errors, as this is the specific error we are handling in this case in testRangeValidate() test method. With this change, the test now passes as expected.
Moving this back to Needs Review.Kindly review.