? ? PHP 8.x Pending

User tests: Successful: Unsuccessful:

avatar joomdonation
joomdonation
25 Mar 2022

Pull Request for Issue # .

Summary of Changes

This PR fixes deprecated warning for Calendar form field (use in core which all has translateformat="true" in it's form field definition). For calendar form field does not have translateformat="true", we need a different PR. I think this is safe to go in 4.1 to prevent warnings like this in core.

Testing Instructions

  1. Use Joomla 4 on PHP 8.1
  2. Go to System -> Global Configuration, set Error Reporting to Maximum
  3. Edit an article, look at Publishing tab

Actual result BEFORE applying this Pull Request

You would see some deprecated warnings like:

Deprecated: Function strftime() is deprecated in /libraries/src/Form/Field/CalendarField.php on line 277

Expected result AFTER applying this Pull Request

No deprecated warning anymore, the date time you select for Start Publishing, Finish Start Publishing... are being saved properly.

Documentation Changes Required

None

avatar joomdonation joomdonation - open - 25 Mar 2022
avatar joomdonation joomdonation - change - 25 Mar 2022
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 25 Mar 2022
Category Libraries
avatar laoneo
laoneo - comment - 25 Mar 2022

I would love to see a way, that extensions can define a filter format (not sure why it has that name) in the XML. Can you add that @joomdonation?

avatar joomdonation
joomdonation - comment - 25 Mar 2022

Yes, in second PR #37376 (via filterformat attribute). For this PR, I want to have safe fix which can go into 4.1. It prevent deprecated warnings for calendar form fields use in core.

avatar joomdonation joomdonation - edited - 25 Mar 2022
avatar laoneo
laoneo - comment - 25 Mar 2022

I have tested this item successfully on ce908fe


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37373.

avatar laoneo laoneo - test_item - 25 Mar 2022 - Tested successfully
avatar joomdonation
joomdonation - comment - 26 Mar 2022

I will see if I can make a pr for 4.1 which will also work for extensions based on this one as I have a bad feeling shipping core for the next months with no way for extension developers to use a core field without a warning on PHP 8.1.

@laoneo All we need to do is add one more line of code to this PR:

$this->filterFormat = (string) $this->element['filterformat'] ? (string) $this->element['filterformat'] : '';

Then extension developers can just add filterformat attribute with right value to his field and it will work well. It is backward compatible, does not change any existing behavior. It is just if maintainers (especially @bembelimen ) want to accept this change to 4.1.

avatar laoneo
laoneo - comment - 26 Mar 2022

I don't see this as an issue not to get merged into 4.1 as the benefit is high enough to have a clean way. For 4.2 we can then even deprecate the old format attribute. What I was thinking of is that the name filterformat is a bit strange.

avatar joomdonation
joomdonation - comment - 26 Mar 2022

For 4.2 we can then even deprecate the old format attribute

We use that format in calendar javascript code, so it could not be deprecated

What I was thinking of is that the name filterformat is a bit strange

Yes, agree. I guess it is named like that because the format is used in filter method of the field https://github.com/joomla/joomla-cms/blob/4.1-dev/libraries/src/Form/Field/CalendarField.php#L358-L361.

avatar exstreme
exstreme - comment - 7 Apr 2022

I have tested this item 🔴 unsuccessfully on ce908fe

Deprecated: Function strftime() is deprecated in C:\OpenServer\domains\joomla.test\libraries\src\Form\Field\CalendarField.php on line 285

But I can it reproduce only in custom extension https://github.com/exstreme/Jcomments-4/releases by editing any comment


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37373.

avatar exstreme exstreme - test_item - 7 Apr 2022 - Tested unsuccessfully
avatar joomdonation
joomdonation - comment - 8 Apr 2022

@exstreme As mentioned, this PR only fixes the issue for calendar form fields use in Joomla core (which has translateformat="true" in the field definition). For calendar form fields use by third party extension, more change is needed, one possible solution could be #37373 (comment) . However, that needs to be a new PR for 4.2. For this PR, I only made small change, not introduce a new thing so that it could be merged into 4.1.

avatar exstreme
exstreme - comment - 8 Apr 2022

I have tested this item successfully on ce908fe


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37373.

avatar exstreme exstreme - test_item - 8 Apr 2022 - Tested successfully
avatar richard67 richard67 - edited - 8 Apr 2022
avatar richard67 richard67 - change - 8 Apr 2022
Status Pending Ready to Commit
Labels Added: ? ?
avatar richard67
richard67 - comment - 8 Apr 2022

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37373.

avatar Quy Quy - change - 8 Apr 2022
Labels Added: ? PHP 8.x
Removed: ?
avatar bembelimen
bembelimen - comment - 12 Apr 2022

Puh, I see what you did there and it's the most painless solution without rewriting everything I guess but as you stated also not a full solution.
So could you make a remark in the code (or make a deprecation PR for 4.2?), that is has to be changed in the future and create a 5.0 issue (release blocker?) that this has to be fixed.

avatar joomdonation
joomdonation - comment - 13 Apr 2022

@bembelimen I also made a PR #37376 for 4.2 which could be the full solution. The purpose of this PR is prevent warnings for Calendar fields use in Joomla core and I think it should be merged for 4.1

avatar rdeutz rdeutz - change - 20 Apr 2022
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2022-04-20 10:23:02
Closed_By rdeutz
avatar rdeutz rdeutz - close - 20 Apr 2022
avatar rdeutz rdeutz - merge - 20 Apr 2022

Add a Comment

Login with GitHub to post a comment