No Code Attached Yet Information Required
avatar aberenguer78
aberenguer78
2 Dec 2024

Steps to reproduce the issue

When opening my custom module appears this deprecation error:
Deprecated: Automatic conversion of false to array is deprecated in C:\xamppPHP8.2\htdocs\joomla5\libraries\src\HTML\HTMLHelper.php on line 810

The error message is in joomla root\libraries\src\HTMLHelper.php line 810

Expected result

No deprecation message is shown

Actual result

The deprecation message is shown

System information (as much as possible)

Joomla 5.2.2
PHP 8.3.13

Additional comments

Solution provided by chat gpt:

Solution add this line in 810: (Solution provided by chat gpt - deprecation happens in php 8.2)
$options = is_array($options) ? $options : [];
$options['relative'] = $options['relative'] ?? false;

avatar aberenguer78 aberenguer78 - open - 2 Dec 2024
avatar joomla-cms-bot joomla-cms-bot - change - 2 Dec 2024
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 2 Dec 2024
avatar aberenguer78
aberenguer78 - comment - 3 Dec 2024

The message appears and in my code I applied the solution provided, if you want I can send you a screen shot with the deprecation message refering to that class HTMLHelper

avatar Fedik
Fedik - comment - 3 Dec 2024

Please check how do you add script in your module.
That error can happen when you use old style code, kind of:

JHtml::_('script', 'com_example/example.min.js', $framework, $relative, $pathOnly, $detectBrowser, $detectDebug);

It is outdated since joomla 4 , and it is recomended to use WebassetManager.
You can find more here https://manual.joomla.org/docs/next/general-concepts/web-asset-manager/
Scripts section https://manual.joomla.org/docs/next/general-concepts/web-asset-manager/#working-with-scripts

avatar Fedik Fedik - change - 3 Dec 2024
Labels Added: Information Required
avatar Fedik Fedik - labeled - 3 Dec 2024
avatar aberenguer78
aberenguer78 - comment - 3 Dec 2024

Thanks Fedik but I'm not using the old style of code (old style of code is migrated I have checked). To load scripts and css I use WebAssetManager. If you have a look on the code I provided as solution you'll see that it works.

avatar Fedik
Fedik - comment - 3 Dec 2024

Then please provide the code how do you use WebAssetManager, and we can check.
There is no way that this error can hapen when it is used correctly.

avatar aberenguer78
aberenguer78 - comment - 3 Dec 2024

I'm not going to provide the code because it happens in the form of the module to configure the fields and I'm not allowed to provide code of Joomla of our custom components, and also I checked the code and I don't have any error related to what you explained. That form is configured by Joomla using the manifest XML file with the different type of fields and has nothing strange loading the scripts.
I have migrated components of different Joomla versions of joomla and I consider the error is not related to that. The error is crystal clear, php is more strict and need the extra check provided. If you consider it's other thing and you don't want to apply the fix is not my fault, I have provided the error and the solution, have a good day.

avatar Fedik
Fedik - comment - 3 Dec 2024

You do not need to provide whole module, only piece which call the webasset to add the script.

As for now, the error cannot be reproduced.
Without clear way to reproduce the issue, it will be closed. Thanks.

avatar aberenguer78
aberenguer78 - comment - 3 Dec 2024

It's possible another person review the error provided?? If you close I will reopen again there's no problem for me 👎

avatar Fedik
Fedik - comment - 3 Dec 2024

It's possible another person review the error provided??

Anyone can review, but there still no clear way to reproduce it, therefore you will not get different answer.
Random answer from chat gpt is NOT a solution.
As I already commented earlier the error can come from misuse of the script metthod.

avatar aberenguer78
aberenguer78 - comment - 3 Dec 2024

Sorry but I think that you have a wrong concept of chat gpt. Chat gpt is a powerfull tool and doesn't provide random answers. Has a big knowledge base behind and always provide different solutions. I think nowadays a lot of developers are using it.

avatar brianteeman
brianteeman - comment - 3 Dec 2024

It's possible another person review the error provided?? If you close I will reopen again there's no problem for me 👎

Without seeing your code (just the relevant snippet) it is impossible to help you further

avatar rdeutz rdeutz - close - 3 Dec 2024
avatar rdeutz
rdeutz - comment - 3 Dec 2024

If you don't want to give us the needed information to reproduce the error, it doesn't makes sense to keep a conversation going. Closing for now, can be reopened, if you change you mind @aberenguer78

avatar rdeutz rdeutz - change - 3 Dec 2024
Status New Closed
Closed_Date 0000-00-00 00:00:00 2024-12-03 13:48:46
Closed_By rdeutz

Add a Comment

Login with GitHub to post a comment