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

Steps to reproduce the issue

I provide you an image of the error in my configuration form of the module:

Image

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

I detected that in both functions of HTMLHelper.php class have the same issue:

  • public static function stylesheet($file, $options = [], $attribs = [])
  • public static function script($file, $options = [], $attribs = [])

On the first line of each of this functions to avoid the error should be added:

Expected result

No deprecation error is shown

Actual result

A deprecation message appears

System information (as much as possible)

Joomla 5.2.2
PHP 8.3.13

Additional comments

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;

In my scripts I'm not calling directly to this functions, is something done internally by joomla, I haven't find the code that calls to this script function but I think it's something it should be solved.

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

see also closed #44573, #44568.

avatar Fedik
Fedik - comment - 3 Dec 2024

This is not the information you were asked for.
Please check previus comments again.

With spamming you not helping yourself.

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

I have been debugging the module and the functions are called by joomla on loading the configuration form of the module.
Sorry by the confusion in this module I don't have calls to JHTML or the newest HTMLHelper, so the problem is not related to that I think.
What I have seen is that when it's called the function the value of parameter options is false and for this reason is giving the deprecation message.

avatar aberenguer78
aberenguer78 - comment - 4 Dec 2024

Sorry I have seen in a custom field that I have migrated this:
//JHtml::('script', 'system/modal-fields.js', array('version' => 'auto', 'relative' => true));
to this:
HTMLHelper::
('script', 'system/modal-fields.js', false, true);

What would be the correct migration for this line provided??

Altough I probably have a bad call to HMTLHelper I think that It would be nice that you add this line to the functions commented to check the array is correct:

$options = is_array($options) ? $options : [];

avatar brianteeman
brianteeman - comment - 4 Dec 2024

We really would like to help but without seeing the code it is impossible!!

avatar Fedik
Fedik - comment - 4 Dec 2024

HTMLHelper::_('script', 'system/modal-fields.js', false, true);

This is a reason of the PHP warning.
Valid call would be HTMLHelper::_('script', 'system/modal-fields.js', array('version' => 'auto', 'relative' => true));, but it also outdated. In Joomla 5 should be used WebAssetManager.

However 'system/modal-fields.js' is something from Joomla 3 and does not exists anymore, you can remove that line.

avatar aberenguer78
aberenguer78 - comment - 4 Dec 2024

Thanks fedik for the information. I'm migrating to Joomla 5 so what would be the correct code for the call I have shown?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/44574.

avatar aberenguer78
aberenguer78 - comment - 4 Dec 2024

I removed the code you mentioned and all seems to continue working properly

avatar Fedik Fedik - change - 4 Dec 2024
Status New Closed
Closed_Date 0000-00-00 00:00:00 2024-12-04 12:41:50
Closed_By Fedik
avatar Fedik Fedik - close - 4 Dec 2024
avatar Fedik
Fedik - comment - 4 Dec 2024

... what would be the correct code for the call

If you have example:

HTMLHelper::_('script', 'mod_mymodule/my-script.js', array('version' => 'auto', 'relative' => true));

You can use WebassetManager and register your asset with joomla.asset.json, or just:

$wa->registerAndUseScript('mod_mymodule.my-script', 'mod_mymodule/my-script.js');

Can find more at https://manual.joomla.org/docs/next/general-concepts/web-asset-manager/#working-with-scripts
And https://manual.joomla.org/docs/next/building-extensions/modules/module-development-tutorial/step7-javascript/

I removed the code you mentioned and all seems to continue working properly

Yeap, that file does not exists in Joomla 5.

I am closing the issue as not a bug.

Add a Comment

Login with GitHub to post a comment