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
No deprecation message is shown
The deprecation message is shown
Joomla 5.2.2
PHP 8.3.13
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;
Labels |
Added:
No Code Attached Yet
|
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
Labels |
Added:
Information Required
|
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.
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.
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.
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.
It's possible another person review the error provided?? If you close I will reopen again there's no problem for me 👎
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.
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.
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
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
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2024-12-03 13:48:46 |
Closed_By | ⇒ | rdeutz |
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