[4.1] Use the date function in calendar field#37329
[4.1] Use the date function in calendar field#37329laoneo wants to merge 3 commits intojoomla:4.2-devfrom
Conversation
|
I have tested this item ✅ successfully on fca7309 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37329. |
|
Surely this has to go in 4.2 |
|
I have tested this item ✅ successfully on fca7309 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37329. |
|
rtc This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37329. |
|
rtc This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37329. |
|
I have tested this item ✅ successfully on fca7309 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37329. |
Yes, or 5.0 |
|
If this has to go into 5, then Joomla 4 will never be able to run on PHP 9. If it has to go into 4.2, then I suggest an alternative parameter where extension developers can define a format in normal PHP date format. Something like Extension developers can then still use the normal format parameter to keep backwards compatibility with Joomla 3. What do you guys think? |
|
If you go down the route of the extra date_format then you should also update all date fields in joomla so that they are using the new way and nothing in core is using the old and presumably deprecated method. @nibra See I think I understand now your comments in the RFC |
|
Actually, we can use a hidden parameter filterFormat . It is not documented, but used on all of our calendar form fields when translateformat="true" , see https://github.com/joomla/joomla-cms/blob/4.1-dev/libraries/src/Form/Field/CalendarField.php#L207So Calendar Form fields from core will still work as how it is. For third party extensions, we can just add filterFormat attribute with the right value and it is working OK, too. If the attribute is not available, we can use the code to convert format like how we are doing in this PR (maybe just for PHP >= 8.1.0) |
|
@joomdonation can you make an alternative pr with the |
|
@laoneo If it is OK to make PR without writing unit test, I will give it a try (I don't know how to write unit tests at the moment). Also, I will have to borrow the code of strftimeFormatToDateFormat method in this PR. |
|
Sure |
|
CLosing in favor of #37373. |
Pull Request for Issue #34952 and takeover from #36395.
Summary of Changes
The calendar field uses the
strftimeto format a date. This function got deprecated in PHP 8.1 and will be removed in 9. This pr uses the widely accepteddatefunction.There are probably edge cases for format conversion, which are not covered by this pr, but can be added later.
Full credit goes to @PhilETaylor, I was just taking it over and made some small modifications.
Testing Instructions
Actual result BEFORE applying this Pull Request
The following message is displayed:
Deprecated: Function strftime() is deprecated in /libraries/src/Form/Field/CalendarField.php on line 277
Expected result AFTER applying this Pull Request
No error message.