Uh oh!
There was an error while loading. Please reload this page.
[6.x] Fix single-mode date fieldtype crashing when saving with a time - #14880
[6.x] Fix single-mode date fieldtype crashing when saving with a time#14880mynetx wants to merge 1 commit into
Conversation
The Control Panel submits a single date that includes a time as a ['date' => ..., 'time' => ...] array, but processSingle() passed it straight to Carbon::parse(), which throws a TypeError on arrays. This hit the default date field, whose default save format (Y-m-d H:i) makes formatHasTime() true regardless of time_enabled. Combine the date and time into a single string before parsing, and treat a missing date as an empty value. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
8cb8a9e to
8421624Compare| // parse an array. A missing date means the field was left empty. | ||
| if (is_array($data)) { | ||
| if (! ($data['date'] ?? null)) { | ||
| return null; |
There was a problem hiding this comment.
can we use the array helpers here to remove the double if?
jasonvarga
commented
Jul 6, 2026
The CP does not submit the array |
jasonvarga
left a comment
There was a problem hiding this comment.
The CP does not submit the array [date, time] anymore. That changed in 6.0. Where are you still seeing this happen?
This PR is attempting to fix a situation that shouldn't happen.
Reviewing as "Requesting changes" so we don't unintentionally merge until hearing reasoning.
mynetx
commented
Jul 6, 2026
Thanks both, you're right. I dug in and can confirm the 6.x CP never submits the Why I opened it: the issue came with a clean stack trace at It doesn't. The 6.0 date rewrite (#11647) moved single mode to plain ISO strings, So this fixes a path that can't be reached. Closing it. Sorry for the noise, and thanks for the quick catch. |
Saving an entry with a single-mode
datefield whose format includes a time throws aTypeError. The CP submits the value as a['date' => ..., 'time' => ...]array, butprocessSingle()passed it straight toCarbon::parse(), which can't parse arrays. This hits the default date field, since the default save format (Y-m-d H:i) makesformatHasTime()true regardless oftime_enabled.This combines the date and time into a single string before parsing.
Fixes#14860