Skip to content
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

[4.x] Fix whereTime affecting the date as well as time #9360

Merged
merged 2 commits into from
Jan 19, 2024

Conversation

ryanmitchell
Copy link
Contributor

@ryanmitchell ryanmitchell commented Jan 19, 2024

For a bit of context, check out: mitydigital/statamic-scheduled-cache-invalidator#3 (comment)

The add-on was passing a full date string to whereTime... eg whereTime('2023-01-01 09:00'), which I hadn't accounted for. This meant it worked like whereDateTime() setting the whole date to that time, which unfortunately doesn't exist. I feel like Carbon should have been handling this possibility in their setTimeFromTimeString method, but they weren't.

The result was that it would get the date matches for that date only, ignoring any others that have a matching time but a different date, which isnt how whereTime is meant to work.

Anyway, its an edge case, and it was quite a nice bug as it made queries simpler, but its not the same behaviour as eloquent, so you would get different results between the two query builders.

The fix was to do a similar value modification in whereTime to what we do in whereDate, so we only use the time part of the date string.

@ryanmitchell ryanmitchell changed the title [4.x] Fix whereTime considering the date as well as time [4.x] Fix whereTime affected the date as well as time Jan 19, 2024
@ryanmitchell ryanmitchell changed the title [4.x] Fix whereTime affected the date as well as time [4.x] Fix whereTime affecting the date as well as time Jan 19, 2024
@jasonvarga jasonvarga merged commit 3e0ed10 into statamic:4.x Jan 19, 2024
22 checks passed
@ryanmitchell ryanmitchell deleted the fix/where-time-issues branch January 19, 2024 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants