Closed (fixed)
Project:
Drupal core
Version:
11.x-dev
Component:
base system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
7 Oct 2021 at 11:19 UTC
Updated:
20 Feb 2026 at 23:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
hayashi commentedComment #6
smustgrave commentedThis 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.
This will need a test case to show the issue as a next step.
Thanks
Comment #7
akram khanadded patch against 10.1.x and fixed some coding standard issues
Comment #8
nitin shrivastava commentedFix command failures #7.
Comment #9
Abhisheksingh27 commentedAdding Reroll for 10.1.x
Comment #10
smustgrave commentedPlease see the tags before moving status this needs tests
Comment #11
_pratik_CCF fixes found in #9
Comment #15
dcam commentedThe patch from #2 was converted to an MR. Later patches included unrelated code style changes. I also added new cases to the existing test data provider.
Comment #16
smustgrave commentedThink if someone incorrectly passes a string we should maybe log or throw an error so people know they need to fix their code.
Comment #17
dcam commentedI disagree. This is a validation function. It seems inappropriate for validation to throw an error if something doesn't validate. Logging, maybe, but I think even that's a stretch. It should be up to calling code to decide what to do if validation doesn't pass.
The only place in Core where this is called is in
DateTimePlus::createFromArray()in the same class.::createFromArray()throws an exception if validation failed. So it's doing the job.Comment #18
smustgrave commentedI'll leave this one for others to review then.
Comment #19
smustgrave commentedSince no one else has reviewed in 2 months and my hesitation isn't something I feel so strong about to block I'm going to mark as the fix is straight forward.
Comment #20
xjmAt first I was confused by this, because I was expecting the date parts to allow valid month formats like "January", but it does indeed expect it to be integers.
There's an argument to be made that
checkArray()should be a protected method, for the reason in #17.Since
intis expected, I am not sureis_numeric()goes far enough, since that could be floats and whatnot. It should be an int, or a string whose numeric value is an int.I agree letting the caller handle throwing the exception is fine, and let's open a followup to discuss whether we should deprecate this being public and make it protected next major.
Thanks!
Comment #21
xjmRetitling to make it clear we're not "handling" them (which would be brittle and hide bugs). We're returning FALSE to trigger an exception in the caller. The original title had me all set to NW it but the approach is actually sound.
Comment #22
xjmComment #23
dcam commentedFeedback has been addressed.
Comment #24
smustgrave commentedMind opening the follow up ticket mentioned in #20
Comment #25
dcam commentedThe follow-up was created at #3566186: Make DateTimePlus::checkArray() protected.
Comment #26
dcam commentedComment #27
smustgrave commentedThanks rest LGTM!
Comment #29
alexpottSo this change results in a slightly different behaviour. It's a bit of an edge case but if you call the function with a float
On HEAD
With MR
However I think is is okay because with the MR if you do
It's fine so it'll still accept floats but not ones that don;t represent an integer and passing a value that is not an integer to day, month or year makes no sense. However given this very slight behaviour change I'm going to only merge to main and 11.x
Comment #30
alexpottCommitted and pushed 22f99645e25 to main and 108cf90c63c to 11.x. Thanks!