User tests: Successful: Unsuccessful:
Pull Request for Issue #34952 and takeover from #36395.
The calendar field uses the strftime
to format a date. This function got deprecated in PHP 8.1 and will be removed in 9. This pr uses the widely accepted date
function.
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.
The following message is displayed:
Deprecated: Function strftime() is deprecated in /libraries/src/Form/Field/CalendarField.php on line 277
No error message.
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries Unit Tests |
Surely this has to go in 4.2
I have tested this item
Labels |
Added:
?
?
?
|
rtc
Status | Pending | ⇒ | Ready to Commit |
rtc
I have tested this item
Surely this has to go in 4.2
Yes, or 5.0
Labels |
Added:
?
PHP 8.x
Removed: ? |
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 date_format
. So the tag would look like:
<field
name="begin"
type="calendar"
label="COM_BANNERS_BEGIN_LABEL"
hint="COM_BANNERS_BEGIN_HINT"
format="%Y-%m-%d"
date_format="Y-m-d"
filter="user_utc"
/>
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 filterFormat
? But please make it compatible with all PHP versions.
Sure
Status | Ready to Commit | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-03-25 16:19:40 |
Closed_By | ⇒ | laoneo | |
Labels |
Added:
?
Removed: ? |
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.