A php warning can be thrown at line 666 in /libraries/joomla/document/document.php
if variable $argList[3] is not an array.
A simple fix would be to include an array check in the if statement, like this:
if (isset($argList[3]) && $argList[3] && is_array($argList[3]))
original if statement:
if (isset($argList[3]) && $argList[3])
Status | New | ⇒ | Information Required |
Hello,
We are using 3.7.5
The issue is real.
I have tried to implement the fix and it solves the problem.
So the fix is to replace the old lin 667:
if (isset($argList[3]) && $argList[3])
with:
if (isset($argList[3]) && $argList[3] && is_array($argList[3]))
Ah Line 667 ;)
Do you know how to do a pull request? So we can include the changes linked to your account as submitter and fixer of the bug.
The line you mention can be found here: https://github.com/joomla/joomla-cms/blob/staging/libraries/src/Document/Document.php#L679
Let me know when you need help in doing the pull request.
I have never tried making a pull request before.
Please advice what to do :)
How to make a Pull Request.
Maybe this is a bit simpler to understand & follow: https://docs.joomla.org/Using_the_Github_UI_to_Make_Pull_Requests @fabelmik Let me know when you have any questions about it.
Thanks.
This does not need fixing,
in legacy signature (code below is from J3.4.x) the argument 4 aka the $argList[3] is supposed to be an array !
/**
* Adds a linked stylesheet to the page
*
* @param string $url URL to the linked style sheet
* @param string $type Mime encoding type
* @param string $media Media type that this stylesheet applies to
* @param array $attribs Array of attributes
*
* @return JDocument instance of $this to allow chaining
*
* @since 11.1
*/
public function addStyleSheet($url, $type = 'text/css', $media = null, $attribs = array())
{
$this->_styleSheets[$url]['mime'] = $type;
$this->_styleSheets[$url]['media'] = $media;
$this->_styleSheets[$url]['attribs'] = $attribs;
return $this;
}
see that $argList[3] aka $attribs was supposed to be an array
the problem is at the caller and not at the API method !
@ggppdk does your Comment mean there is no Pull Request necessary?
Exactly, there is no bug, nothing to be fixed
because the legacy signature stated that $attribs needs to be an array
above i mentioned J3.4
but please look at $attribs at J1.7 docs
https://docs.joomla.org/API17:JDocument::addStyleSheet
since then it was an array
the fault is at the caller, the caller of addStyleSheet , is calling addStyleSheet with a bad argument,
so the caller needs to make the fix
Status | Information Required | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-08-26 06:47:50 |
Closed_By | ⇒ | franz-wohlkoenig |
Closed_By | franz-wohlkoenig | ⇒ | joomla-cms-bot |
Set to "closed" on behalf of @franz-wohlkoenig by The JTracker Application at issues.joomla.org/joomla-cms/17600
closed as stated above. Thanks for Answer @ggppdk
hello i am a programmer in this web page (my cms page is joomla )and i have this problem on my module.
Warning: array_replace(): Argument #2 is not an array in /srv/disk12/1725192/www/users.com/libraries/joomla/document/document.php on line 673
and my php document code :
/**
* Adds a linked stylesheet to the page
*
* @Param string $url URL to the linked style sheet
* @Param array $options Array of options. Example: array('version' => 'auto', 'conditional' => 'lt IE 9')
* @Param array $attribs Array of attributes. Example: array('id' => 'stylesheet', 'data-test' => 1)
*
* @return JDocument instance of $this to allow chaining
*
* @SInCE 11.1
* @deprecated 4.0 The (url, mime, media, attribs) method signature is deprecated, use (url, options, attributes) instead.
*/
public function addStyleSheet($url, $options = array(), $attribs = array())
{
// B/C before 3.7.0
if (is_string($options))
{
JLog::add('The addStyleSheet method signature used has changed, use (url, options, attributes) instead.', JLog::WARNING, 'deprecated');
$argList = func_get_args();
$options = array();
$attribs = array();
// Old mime type parameter.
if (!empty($argList[1]))
{
$attribs['type'] = $argList[1];
}
// Old media parameter.
if (isset($argList[2]) && $argList[2])
{
$attribs['media'] = $argList[2];
}
// Old attribs parameter.
if (isset($argList[3]) && $argList[3])
{
$attribs = array_replace($attribs, $argList[3]);
}
}
// Default value for type.
if (!isset($attribs['type']) && !isset($attribs['mime']))
{
$attribs['type'] = 'text/css';
}
$this->_styleSheets[$url] = isset($this->_styleSheets[$url]) ? array_replace($this->_styleSheets[$url], $attribs) : $attribs;
if (isset($this->_styleSheets[$url]['options']))
{
$this->_styleSheets[$url]['options'] = array_replace($this->_styleSheets[$url]['options'], $options);
}
else
{
$this->_styleSheets[$url]['options'] = $options;
}
return $this;
}
how to problem;
how to fix it ;
@ggppdk and others, could you please be so kind and make sure you are tagging the correct persons? It has now happened numerous times, that people have been tagging me instead of [at]franz-wohlkoenig in issues. That results in an unnecessary distraction for me as well as Franz not being informed of the mention.
Thank you guys. Happy Coding
(Sorry for hijacking this issue to state that, but there's no other way for me to inform you)
@fabelmik can you please check which version do you use? And if you don't use 3.7.5 please update to 3.7.5 and try it again. As the line you point to is a inline comment: https://github.com/joomla/joomla-cms/blob/3.7.5/libraries/joomla/document/document.php#L666 Therefor this line can not throw a error.
Thanks,