Skip to content
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

Deprecated: trim(): Passing null to parameter #1 ($string) #41803

Closed
Sulpher opened this issue Sep 19, 2023 · 4 comments
Closed

Deprecated: trim(): Passing null to parameter #1 ($string) #41803

Sulpher opened this issue Sep 19, 2023 · 4 comments
Labels
No Code Attached Yet PHP 8.x PHP 8.x deprecated issues

Comments

@Sulpher
Copy link

Sulpher commented Sep 19, 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.

@Ruud68
Copy link
Contributor

Ruud68 commented Sep 21, 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>

@Fedik Fedik added the PHP 8.x PHP 8.x deprecated issues label Sep 21, 2023
@b2z
Copy link
Member

b2z commented Oct 18, 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?

@Ruud68
Copy link
Contributor

Ruud68 commented Oct 20, 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

@Hackwar
Copy link
Member

Hackwar commented Mar 27, 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.

@Hackwar Hackwar closed this as completed Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
No Code Attached Yet PHP 8.x PHP 8.x deprecated issues
Projects
None yet
Development

No branches or pull requests

6 participants