Pending
Pull Request for # 15548
Referenced as Duplicate of: # 16174

User tests: Successful: Unsuccessful:

avatar chrislewis60
chrislewis60
27 Apr 2017

Pull Request relating to Issue #15548 and #15600.

'stylesheet' function in /libraries/cms/html/html.php takes an $options which may or may not be an array. After upgrading to Joomla 3.7 I was seeing 'Cannot use a scalar value warning' warnings displayed in the frontend website relating to lines 620, 621, 622 and 623. There have been some changes to this function in the last couple of days - I don't know whether there has been an unintended consequence as a result.

Summary of Changes

In the section that produced warnings, the $options variable is expected to be an array. I've added a check to say that if it's not an array then define it as an empty array. If it is already an array then there is no impact. The code is expecting it to be an array.

Testing Instructions

Just tested in the browser. No automated tests added.

Expected result

No 'Cannot use a scalar value warning' warnings

Actual result

Documentation Changes Required

None.

Votes

# of Users Experiencing Issue
2/2
Average Importance Score
4.50

avatar chrislewis60 chrislewis60 - open - 27 Apr 2017
avatar chrislewis60 chrislewis60 - change - 27 Apr 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 27 Apr 2017
Category Libraries
avatar chrislewis60
chrislewis60 - comment - 5 May 2017

I don't know whether adding a return directly after } is a safe thing to do - there are lines below it (624-627) that may still need to be executed. My amend is simply ensuring that $options is an Array before it gets to the code below it so that the warnings about it not being an array are suppressed. I don't know if there are any knock on consequences of this amend - I just know that in my installation it was the only way that I found to suppress the frontend warnings without breaking the admin area as well.

avatar mbabker
mbabker - comment - 5 May 2017

We need a proper test case for this and not just using review here. How is JHtml::stylesheet() being called that triggers the warning?

avatar Bakual
Bakual - comment - 5 May 2017

I also like Michael think we should find where the warning origins, because apparently there is code somewhere which calls that method wrong.

avatar polc1410
polc1410 - comment - 18 May 2017

I'm getting this issue appearing following a 3.6.5 to 3.7.1 upgrade.
I can obviously patch the file but:
(a) what do we need to do to get that into 3.7.2
(b) do you want me to try and isolate what calls the code in the firt place?

avatar Quy
Quy - comment - 18 May 2017

a) submit a pr
b) Yes per Bakual:

I also like Michael think we should find where the warning origins, because apparently there is code somewhere which calls that method wrong.

avatar Bakual
Bakual - comment - 18 May 2017

do you want me to try and isolate what calls the code in the firt place?

Yep, that would be very interesting if you can get that information.

avatar polc1410
polc1410 - comment - 18 May 2017

OK. So I've traced the issue to three calls to style sheets:
1. https://{mydomain-removed}/administrator/components/com_joooid/views/configuration/tmpl/joooidcontent.css $options = 1
Joooid is an extension (http://www.joooid.com), and disabling its plugin called:
Joooid Content stops it generating issues. Line 43 of its file: "joooidcontent.php" is currently:
JHtml::stylesheet(JUri::base() . 'administrator/components/com_joooid/views/configuration/tmpl/joooidcontent.css', true);
Updating this to:
$options = array(); $attribs=(); JHtml::stylesheet(JUri::base() . 'administrator/components/com_joooid/views/configuration/tmpl/joooidcontent.css', $options,$attribs, true);
Resolves the issue. I've raised a bug report with joooid although not sure if/when they will fix as v2.6 hasn't had any updates since 2015.

2. tooltips/style.min.css $options was empty
Tooltips is a plugin.
This was a grossly out dated version (v3.7.9 now on 7.0.9) - I haven't been able to update it yet as I need to increase my PHP version. Will post an update on that once I know more.

3. $file was empty but $options contained: "templates/system/css/system.css"
I haven't yet found what is going on with this. Will post back on that shortly

avatar polc1410
polc1410 - comment - 18 May 2017

OK now found source for 3 is JA Elastica Template: file /templates/ja_elastica/blocks/head.php lines #32 and 33
`

`

Bug report here: https://www.joomlart.com/forums/topic/joomla-3-7-update-status/page/8/#post-1035193

So I don't think there is a fault in the core calling the function, but there is clearly a number of "dodgy" calls in older code. SO I think putting the fix in would make sense. But with a depreciation error

avatar wojsmol
wojsmol - comment - 21 May 2017

I have tested this item successfully on b34f620

code review


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

avatar wojsmol wojsmol - test_item - 21 May 2017 - Tested successfully
avatar Bakual
Bakual - comment - 21 May 2017

I tend to say this PR isn't something we should do, as it is only a bandaid for faulty code in 3rd party extensions. It should be fixed in the respective extensions.

If we're going to do something like this, then it has to be deprecated right away with at least a log message. But then, the current warning is fine as the code still works and the extension developer gets notified of his faulty code right away. On productive servers, those warnings should be disabled anyway.

avatar mbabker mbabker - change - 21 May 2017
Rel_Number 15548
Relation Type Pull Request for
avatar mbabker mbabker - edited - 21 May 2017
avatar mbabker mbabker - change - 21 May 2017
Title
define $options as an array if its not already an array - the code is expecting an array.
define $options as an array if its not already an array - the code is expecting an array.
avatar Quy
Quy - comment - 22 May 2017

Here is a call from Joomlart's Elastica template in Joomla! 3.4.8:
$document->addStylesheet($url[1], $attrs['mime'], $attrs['media'], $attrs['attribs']);

avatar Bakual
Bakual - comment - 22 May 2017

@Quy That one is actually fine and still works. It has been deprecated with J3.7.0 and will not supported anymore with J4.0. Currently it logs a deprecation message if you use it that way.

avatar franz-wohlkoenig franz-wohlkoenig - change - 24 May 2017
Status Pending Needs Review
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 24 May 2017

set Status on "Needs Review" cause of above Comment.


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

avatar Quy
Quy - comment - 17 Oct 2017

Can this be closed per @Bakual comment?

avatar franz-wohlkoenig franz-wohlkoenig - change - 18 Oct 2017
Status Needs Review Closed
Closed_Date 0000-00-00 00:00:00 2017-10-18 05:52:25
Closed_By franz-wohlkoenig
avatar joomla-cms-bot joomla-cms-bot - change - 18 Oct 2017
Closed_By franz-wohlkoenig joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 18 Oct 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 18 Oct 2017

closed as stated above.


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

avatar joomla-cms-bot
joomla-cms-bot - comment - 18 Oct 2017
avatar chrislewis60
chrislewis60 - comment - 27 Mar 2018

Many months later I actually discovered that it was the Joooid plugin that http://www.joooid.com/ that caused this issue. Once disabled the warnings went away. It may have been updated now but if anyone sees this issue again, try disabling the Joooid plugin.

Add a Comment

Login with GitHub to post a comment