No Code Attached Yet PHP 8.x
avatar Sulpher
Sulpher
19 Sep 2023

I have been installed Joomla 5 beta 1 for testing and running it on PHP 8.2 and discovered the following notice:

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home//public_html//libraries/vendor/joomla/registry/src/Format/Json.php on line 55

It occurs in a 3rd party extension, but according to the character of the notice, it is related to the core code.

avatar Sulpher Sulpher - open - 19 Sep 2023
avatar joomla-cms-bot joomla-cms-bot - change - 19 Sep 2023
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 19 Sep 2023
avatar Ruud68
Ruud68 - comment - 21 Sep 2023

Seeing multiple of these deprecated notices also on J4 (see below for two recent examples). Question for me is: should these Joomla functions validate extension input (like on submitting a form you should always validate user input), or do we trust the developers here?

if a string is expected, then passing null should either be type casted or it should throw an error (for the extension dev to fix):

Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/vhosts/xyz/j4/libraries/src/Extension/ExtensionManagerTrait.php on line 45

Deprecated: substr(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/vhosts/xyz/j4/plugins/system/languagefilter/languagefilter.php on line 718
```<hr /><sub>This comment was created with the <a href="https://github.com/joomla/jissues">J!Tracker Application</a> at <a href="https://issues.joomla.org/tracker/joomla-cms/41803">issues.joomla.org/tracker/joomla-cms/41803</a>.</sub>
avatar Fedik Fedik - change - 21 Sep 2023
Labels Added: PHP 8.x
avatar Fedik Fedik - labeled - 21 Sep 2023
avatar b2z
b2z - comment - 18 Oct 2023

Another one in a third party plugin:

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /libraries/src/Plugin/PluginHelper.php on line 64

And my question is the same as Ruud asked - who is responsible for this, core or developers?

avatar Ruud68
Ruud68 - comment - 20 Oct 2023

In my reported issue I proposed a solution: if that is approved then it is a nobrainer in quickly fixing these notices for php 8.2 by doing PR's when we run into one.
#41783

avatar Hackwar Hackwar - change - 27 Mar 2024
Status New Closed
Closed_Date 0000-00-00 00:00:00 2024-03-27 14:23:55
Closed_By Hackwar
avatar Hackwar Hackwar - close - 27 Mar 2024
avatar Hackwar
Hackwar - comment - 27 Mar 2024

This is the responsibility of the third party developers. They have to check if they actually are handing over any data and not null. The docblocks of the methods are very clear about this and require strings in this area. We should also not silently cast this to string or something like that to make the notice go away, since it actually points to a larger issue in the third party extension. Since this is not a Joomla bug, but one of third party devs, I'm closing this one.

Add a Comment

Login with GitHub to post a comment