[5.4] Fix crash in Calendar field with invalid date format#46833
[5.4] Fix crash in Calendar field with invalid date format#46833muhme merged 8 commits intojoomla:5.4-devfrom
Conversation
|
@krishnagandhicode Please fix the code style errors reported here: https://github.com/joomla/joomla-cms/actions/runs/21680625878/job/62514601493?pr=46833 First of all use spaces and not tabs for indentation. |
Thanks, on it : ) |
|
Note for testers - you don't need to create a custom field. Any calendar field such as start publishing can be used |
|
I cannot reproduce the issue. P.S. I did not create a custom field (as suggested by Brian). |
@mariantanase Thanks for testing. To reproduce the Fatal Error (Crash), please try this:- Enter: 202655-02-04 (Year 202655) That should trigger the fatal exception we are trying to fix. |
|
Thanks for the re-test, @mariantanase! yes, that is the intended behavior now - it correctly identifies the specific field label in the exception message. |
|
@mariantanase So your test result looks like a successful test to me. If you agree, please go to this PR in the issue tracker here https://issues.joomla.org/tracker/joomla-cms/46833 and use the blue "Test this" button at the top left corner to submit your test result. Thanks in advance, and thanks for testing. |
|
I have tested this item ✅ successfully on 83b1c50 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46833. |
|
I have tested this item ✅ successfully on 83b1c50 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46833. |
Thanks Emmanuel :) |
|
RTC - This PR is ok as bug fix in 5.4-dev as it does not change behaviour, only improves the error message. But further improvements in future versions (6.x) might be useful. Or we remove the calendar field and use a generic one on the long run. This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46833. |
|
I have tested this item ✅ successfully on 83b1c50 An error has occurred.0 Call to a member function format() on false An error has occurred.0 0 Invalid field: Calendar This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46833. |
|
✅ Final test before merge using JBT
|
|
Thank you @krishnagandhicode for your contribution. Thank you @richard67, @Fedik and @brianteeman for your support. Thank you @mariantanase, @exlemor and @gioacchino54 for testing. |
…6833) * [5.4] Fix crash in Calendar field with invalid date format






Pull Request fixes #46708
Summary of Changes
This PR fixes a fatal error (
Call to a member function format() on bool) that occurs when a Calendar field receives an invalid date format.Previously,
CalendarField::filter()did not check ifDateTime::createFromFormat()failed (returnedfalse), leading to a crash when calling->format()when the result is boolean.Testing Instructions
202655-02-0401-01-200566Actual result BEFORE applying this Pull Request
The site crashes with
0 Call to a member function format() on bool.Expected result AFTER applying this Pull Request
The site displays a Error Page (Exception) with a clear message identifying the specific field:
"An error has occurred. 0 Invalid field: Start Publishing" (or the label of the specific field being tested, e.g: "Invalid field: Created Date").
The save is blocked, and the page reloads gracefully.
A specific error message appears identifying the broken field: "Invalid field: Start Publishing" (or the label of your custom field).
Note: I am relatively new to contributing to the core codebase, I am very open to feedback, If there is a preferred way to handle the translation keys or validation logic, I would appreciate your guidance!
Link to documentations
Please select:
Documentation link for guide.joomla.org:
No documentation changes for guide.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed