-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHP 8.1: strftime() is deprecated - Support CalendarField.php for PHP 8.1 #41266
Conversation
PHP 8.1: strftime() is deprecated
@korenevskiy Will this solve issue #41265 ? If so, please link to the issue at the top of the description of this PR ( |
This will not work, there were other PR somewhere around.
|
Doesn't work - sorry |
joomla-cms/libraries/src/HTML/HTMLHelper.php Line 1251 in 5ce99f2
|
@wilsonge That helper method is not used by Calendar Form Field, so it is unrelated. It was created to address the deprecated warnings HTMLHelper calendar in method with with the most common DateTime format parameters (until we a better solution). |
in site https://www.php.net/manual/en/function.strftime.php $format = HTMLHelper::strftimeFormatToDateFormat($this->format);
$this->value = (new DateTime($this->value))->format($format); In the corrected format, we use DateTime object. The function also converts the format to a new one for DateTime. |
Let's create a static method
|
@korenevskiy The right solution is adding filterformat to your field <field name="date_start" type="calendar" default="NOW" filterformat="Y-m-d"
label="MOD_MULTIMODULE_FIELD_FILTERDATESTART_LABEL" showon="date_is:on"
showtime="false" singleheader="true" /> Then it will work well. No warnings anymore. |
But where is backward compatibility? The CALENDAR field should work without the filters attribute. |
It was PHP, not Joomla! introduced that backward incompatible change and Joomla! already provided you the solution with the undocumented There is no reliable way to to convert all the format parameters supported by strftime to format parameters uses by DateTime class, so you cannot do the magic conversion (there are some format parameters in strftime has no equivalent format in DateTime class). |
We need to ensure backward compatibility with older codes. At the same time, support PHP 8.2. At the same time, the format field should fully support backward compatibility, with full support strftime() Let's create a static method
|
Colleagues, I added a static
|
No matter how stupid this way of solving the problem would not be. This is the only way that meets all the requirements. There are no other ways. |
@korenevskiy do not waste your time, re-implementing of |
Of course that is wrong. For example, Joomla 5 should support PHP 8. Which means We can't release a release with an error popping up. There is another option to abandon the old format support. But it's also a backward compatibility violation. I wouldn't waste time if I didn't weigh the options. My option is very bad, BUT it is the only one that will allow you to maintain backward compatibility without errors. And already with the release of Joomla 6, this method can be removed. There is another option, to pretend that nothing is happening. Meanwhile, 100% of Joomla 4 users on PHP 8.1 will display an error. |
There is another option. We simply write the contents of this function into the CalendarField class. This will allow, as you say, not to create new functions. But even such a swollen Calendar FIeld is even worse than my version. |
Each participant will believe that there will be a magic way of 3 lines that will solve all the problems, and will think that someone else will guess for sure. I read the contents of this function. And I will say that it will not be possible to replace it with 3 lines. There is absolutely no way to replace it. |
It works. It not an error, it a warning for developers. |
A proper fix: Introduce a new property However, this is require changes in calendar.js, new lang constant, and review all our forms. Otherwise, any hacking around |
@Fedik I think we have |
That for But in general the Calendar need a bigger fix, see #41444 |
This pull request has been automatically rebased to 4.4-dev. |
We discussed this PR in the maintainers meeting and would suggest the following. |
As Harald said, |
Explain what it means to make a dependency on the compositor in our case. |
Pull Request for ISSUE: #41265
Summary of Changes
Before:
After
Testing Instructions
This XML code add to XML file module.
Enabled all Errors and enable debug mode.
Change PHP to 8.2 in for this site.
And open configuration this module.
Actual result BEFORE applying this Pull Request
You see error on depricated for function strftime().
Expected result AFTER applying this Pull Request
After change you not see this message.
But this field will be work.