No Code Attached Yet
avatar banchaa
banchaa
14 Dec 2021

Steps to reproduce the issue

Under the path: JROOT/libraries/src/Document/Document.php
Row: 638

After Update from Joomla 3.10.x to Joomla 4.0.x. Fatal error.

Expected result

An Array-Variable initiated as $attribs should be created and a key-value-pair automatically assigned to it.
Key: "type"
Value: "text/css"

Actual result

It's instead breaking the site with a fatal error, because of an avoidable syntax-issue.
See here: https://www.php.net/manual/en/language.types.array.php#language.types.array.syntax.modifying

System information (as much as possible)

--

Additional comments

The syntax is being written, without having the variable explicitly initiated as an array-variable first. For the current syntax ($attribs['type'] = 'text/css';) to properly work, the $attribs variable needs to exist beforehand.

I Replaced the current syntax at row 638 with the following: $attribs = array('type' => 'text/css');

Site works now.

avatar banchaa banchaa - open - 14 Dec 2021
avatar joomla-cms-bot joomla-cms-bot - change - 14 Dec 2021
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 14 Dec 2021
avatar banchaa banchaa - change - 14 Dec 2021
Title
PHP 8.0.13 & Joomla 4.0.x
[4.0]Site didn't work after Update to Joomla 4.0.x with PHP 8.0.13
avatar banchaa banchaa - edited - 14 Dec 2021
avatar banchaa banchaa - change - 14 Dec 2021
Title
[4.0]Site didn't work after Update to Joomla 4.0.x with PHP 8.0.13
[4.0]Site didn't work after update to Joomla 4.0.x with PHP 8.0.13
avatar banchaa banchaa - edited - 14 Dec 2021
avatar banchaa banchaa - change - 14 Dec 2021
The description was changed
avatar banchaa banchaa - edited - 14 Dec 2021
avatar ReLater
ReLater - comment - 18 Dec 2021

the $attribs variable needs to exist beforehand.

from my point of view it does exist. See line https://github.com/joomla/joomla-cms/blob/4.0.5/libraries/src/Document/Document.php#L633
where $attribs is initialized as array().

For me it looks like that other code (3rd extensions?, overrides?, template?) uses method addStyleSheet() wrongly and passes over $attribs with wrong data type instead as of type array. Or maybe it still uses the now completely outdated (url, mime, media, attribs) method signature instead of (url, options, attribs) method signature which is not compatible wit Joomla 4 anymore. See lines from Joomla 3: https://github.com/joomla/joomla-cms/blob/3.10.4/libraries/src/Document/Document.php#L660-L686 that have been removed in Joomla 4.

avatar banchaa
banchaa - comment - 18 Dec 2021

It was indeed a file of an template.

The file of my template has the following code:
$doc = JFactory::getDocument();
$doc->addStyleSheet($template.'/style/responsive.css');

How should be the code written instead if you would like to assist?

Thank you very much in advance!

avatar ReLater
ReLater - comment - 18 Dec 2021

Your posted code is not the most "modern" one but it's correct and doesn't throw a fatal error in Joomla 4.

avatar banchaa banchaa - change - 18 Dec 2021
Status New Closed
Closed_Date 0000-00-00 00:00:00 2021-12-18 15:44:19
Closed_By banchaa
avatar banchaa banchaa - close - 18 Dec 2021

Add a Comment

Login with GitHub to post a comment