J3 Issue ?
avatar FoTo50
FoTo50
22 Jul 2018

As I already mentioned in #16174 ...

Having notices/warnings enabled, you might see several messages like

Warning: Illegal string offset 'relative' in ./libraries/src/HTML/HTMLHelper.php on line 626 (Joomla3.x)
or
Warning: Illegal string offset 'relative' in ./libraries/src/HTML/HTMLHelper.php on line 715 (Joomla4Alpha)

These messages are mostly caused by adding a stylesheet the old way, e.g.:
JHTML::stylesheet(filename,path)
instead of the correct "new" way
$document->addStyleSheet(path-to-css-file)

Of course, the reason is an outdated code (mostly in templates, but also other extensions), but is caused by Joomla itself ... even in Joomla 4Alpha3.

Imho this method should get removed completely to force developers to finally update their code, otherwise this should be corrected by some "if(array_key_exists(...))" to avoid these warnings ;)

Greetz

avatar FoTo50 FoTo50 - open - 22 Jul 2018
avatar joomla-cms-bot joomla-cms-bot - change - 22 Jul 2018
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 22 Jul 2018
avatar franz-wohlkoenig franz-wohlkoenig - change - 22 Jul 2018
Category Libraries Templates (site)
avatar FoTo50 FoTo50 - change - 22 Jul 2018
The description was changed
avatar FoTo50 FoTo50 - edited - 22 Jul 2018
avatar ReLater
ReLater - comment - 22 Jul 2018

Methods script() and stylesheet() are marked inside docblock with:

@ deprecated 4.0 The (file, framework, relative, pathOnly, detectBrowser, detectDebug) method signature is deprecated, use (file, options, attributes) instead.

So, I think the concerning parts will be removed finally in Joomla 4.

avatar franz-wohlkoenig franz-wohlkoenig - change - 22 Jul 2018
Status New Discussion
avatar dgrammatiko
dgrammatiko - comment - 22 Jul 2018

FWIW the proper method to add stylesheets and script ARE and will remain for Joomla 4 the: HTMLHelper::stylesheet and HTMLHelper::script (NOT $document->addStyleSheet)

What was deprecated and will be removed is the option to pass the parameters as comma separated. Now it's mandatory to pass them using an array, eg:
OLD WAY

HTMLHelper::_('script', 'some/path/to/script.js', true, true, false, true);

NEW WAY

HTMLHelper::_('script', 'some/path/to/script.js', array('relative' => true, 'version' => 'auto', 'pathOnly' => false, 'debug' => true);

PLEASE DONT USE $document->addStyleSheet AS YOUR ASSETS WILL NOT BBE OVERRIDABLE!!!

avatar FoTo50
FoTo50 - comment - 23 Jul 2018

I get your point dgrammatiko

But then I recommend to change in HTMLHelper.php at the beginning of public static function stylesheet() from currently
if (!is_array($attribs))
to
if (!is_array($attribs) || !is_array($options))
since the css wont get included with these parameters anyway.

But this way the notices are gone and eventually a deprecated message is logged

avatar dgrammatiko
dgrammatiko - comment - 23 Jul 2018

@FoTo50 please feel free to submit a PR with that code

avatar brianteeman brianteeman - change - 2 Aug 2018
Labels Added: J3 Issue
avatar brianteeman brianteeman - labeled - 2 Aug 2018
avatar brianteeman
brianteeman - comment - 19 Aug 2018

Closed see #21734

avatar brianteeman brianteeman - close - 19 Aug 2018
avatar brianteeman brianteeman - change - 19 Aug 2018
Status Discussion Closed
Closed_Date 0000-00-00 00:00:00 2018-08-19 19:35:33
Closed_By brianteeman

Add a Comment

Login with GitHub to post a comment