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.
An Array-Variable initiated as $attribs should be created and a key-value-pair automatically assigned to it.
Key: "type"
Value: "text/css"
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
--
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.
Labels |
Added:
No Code Attached Yet
|
Title |
|
Title |
|
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!
Your posted code is not the most "modern" one but it's correct and doesn't throw a fatal error in Joomla 4.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-12-18 15:44:19 |
Closed_By | ⇒ | banchaa |
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 asarray()
.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 typearray
. 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.