?
avatar fabelmik
fabelmik
18 Aug 2017

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])

Additional comments

Votes

# of Users Experiencing Issue
1/1
Average Importance Score
3.00

avatar fabelmik fabelmik - open - 18 Aug 2017
avatar joomla-cms-bot joomla-cms-bot - labeled - 18 Aug 2017
avatar zero-24
zero-24 - comment - 18 Aug 2017

@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,

avatar franz-wohlkoenig franz-wohlkoenig - change - 18 Aug 2017
Status New Information Required
avatar fabelmik
fabelmik - comment - 18 Aug 2017

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]))


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17600.
avatar zero-24
zero-24 - comment - 18 Aug 2017

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.

avatar fabelmik
fabelmik - comment - 18 Aug 2017

I have never tried making a pull request before.
Please advice what to do :)


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

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 18 Aug 2017

How to make a Pull Request.

avatar zero-24
zero-24 - comment - 18 Aug 2017

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.

avatar ggppdk
ggppdk - comment - 19 Aug 2017

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 !

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 26 Aug 2017

@ggppdk does your Comment mean there is no Pull Request necessary?


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

avatar ggppdk
ggppdk - comment - 26 Aug 2017

@frankmayer

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

avatar franz-wohlkoenig franz-wohlkoenig - change - 26 Aug 2017
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2017-08-26 06:47:50
Closed_By franz-wohlkoenig
avatar joomla-cms-bot joomla-cms-bot - change - 26 Aug 2017
Closed_By franz-wohlkoenig joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 26 Aug 2017
avatar joomla-cms-bot
joomla-cms-bot - comment - 26 Aug 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 26 Aug 2017

closed as stated above. Thanks for Answer @ggppdk


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

avatar paradisegdevelop
paradisegdevelop - comment - 28 Aug 2017

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 ;

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 28 Aug 2017

As this is a closed Issue you will get low Response; please ask help on the forums.

avatar ggppdk
ggppdk - comment - 28 Aug 2017

@paradisegdevelop

how to fix it ;

Update the call to addStyleSheet to pass proper arguments

avatar frankmayer
frankmayer - comment - 29 Aug 2017

@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)

Add a Comment

Login with GitHub to post a comment