[4.x] Fix whereTime affecting the date as well as time #9360
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.