User tests: Successful: Unsuccessful:
Error: Argument 1 passed to Joomla\Utilities\ArrayHelper::toString() must be of the type array, string given, called in \libraries\joomla\document\renderer\html\head.php on line 119 and defined in libraries/vendor/joomla/utilities/src/ArrayHelper.php on line 104
add an is_array check
Status | New | ⇒ | Pending |
Labels |
Added:
?
|
I'm going to be completely honest. While the core needs to check if (is_array($linkAttr['attribs']))
since the API doesn't validate object types in parameters (typehinting where possible) extensions too need to implement fixes (that are backward compatible) so that if the CMS were to start typehinting values, bugs like this couldn't happen. If you're calling JHtml::stylesheet()
or JDocument::addStyleSheet()
with the parameter for the attribs array as a boolean false (I'm guilty of this and I know there are places in core doing it), your code is wrong according to the method documentation and should be corrected.
Title |
|
ok, added the suggestion. Now it can be reviewed and merged
Right now, yes, because the CMS does not enforce the documented object type (in any place where that can be set, it is documented to be an array, but there are places where a boolean false is given for the parameter). So until 4.0 when the method signatures can change to enforce it being an array (typehint the param), when using those params you'll have to check if they are arrays.
OK, so in 3.x the possibilities for $linkAtrr['attribs']
or $strAttr['attribs']
are boolean false or array. It makes sense that if (is_array(______))
would be sufficent without an else clause to catch other possibilities. (typically I prefer explicit commenting for such cases where if
does not include an else
. Never know when the next person reading the code will assume there is a mistake to fix when really it was just a design choice).
@photodude install kunena, enable the forum menu item on mainmenu.
Frontend: click on it and you will see the error.
Fix on Kunena:
https://github.com/Kunena/Kunena-Forum/pull/3642/files
Got the "Catchable fatal error..." shown in the attached screenshot with today's staging snapshot. Applied this patch and the error doesn't show up anymore.
I have tested this item successfully on 6118048
@Gitjk could you set the test to successfully on issues
I have tested this item successfully on 6118048
Test OK
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-02-05 15:15:35 |
Closed_By | ⇒ | wilsonge |
Milestone |
Added: |
Or @photodude can help with fixing the real bug.