[3.10] [PHP 8.1] Fixes Table User for Date/Date.php warning on login#36799
[3.10] [PHP 8.1] Fixes Table User for Date/Date.php warning on login#36799zero-24 merged 1 commit intojoomla:3.10-devfrom
Conversation
Fixes `Deprecated: DateTime::__construct(): Passing null to parameter #1 ($datetime) of type string is deprecated in /home/beat/www/j/libraries/src/Date/Date.php on line 112` error on login
|
I have tested this item ✅ successfully on 5b18831 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36799. |
|
I have tested this item ✅ successfully on 5b18831 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36799. |
|
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36799. |
|
Should't it be better and easier to understand to set the "now" case in the signature: joomla-cms/libraries/src/Table/User.php Line 465 in 5b18831 |
That would be a change in the signature. Wouldn't that be some kind of a b/c break? |
|
Is changing the default value in the signature a b/c breaking change? I mean other than the same change done later in the code which result into the same behavior? Changing the order or the name is but i would be suprised when changing the default value would be an issue too? I'm missing somehting? |
|
I don't know. Was just asking. |
Changing that function's default parameter from Moreover, changing the default of this Due to the above, I maintain my suggested fix proposal. |
|
Thanks. |
Pull Request for Issue # none
Summary of Changes
Fixes
Deprecated: DateTime::__construct(): Passing null to parameter #1 ($datetime) of type string is deprecated in /home/beat/www/j/libraries/src/Date/Date.php on line 112error on loginA
new \Joomla\Date\Date($date, $tz);requires astringas $date, and defaults to'now'. It does not treat the special case of null, which in PHP 8.1 warns deprecation, so I think that the correct place to fix the null parameter is just above where the default for "now" is NULL, in the call of the below where the default is 'now' and doesn't treat null.Testing Instructions
Code-review or test;
PHP 8.1 with all errors on, and joomla debug on. Then login in front-end, and before redirect it has that warning (at least when CB is installed as CB pauses redirects when there is an error).
Actual result BEFORE applying this Pull Request
Deprecated: DateTime::__construct(): Passing null to parameter #1 ($datetime) of type string is deprecated in /home/beat/www/j/libraries/src/Date/Date.php on line 112error on loginExpected result AFTER applying this Pull Request
That warning disappears.
Documentation Changes Required
None.