No Code Attached Yet
avatar PhilETaylor
PhilETaylor
18 May 2021

Steps to reproduce the issue

$document->setBuffer($contents, 'module', $name);

This block of code is using

$document->setBuffer($contents, 'module', $name);

whereas the setBuffer method signature is:

/**
	 * Set the contents of the document buffer
	 *
	 * @param   string  $content  The content to be set in the buffer.
	 * @param   array   $options  Array of optional elements.
	 *
	 * @return  Document instance of $this to allow chaining
	 *
	 * @since   1.7.0
	 */
	public function setBuffer($content, $options = array())
	{
		self::$_buffer = $content;

		return $this;
	}

Expected result

methods called correctly

Actual result

this code probably doesn't work at all.

System information (as much as possible)

Additional comments

avatar PhilETaylor PhilETaylor - open - 18 May 2021
avatar joomla-cms-bot joomla-cms-bot - change - 18 May 2021
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 18 May 2021
avatar PhilETaylor PhilETaylor - change - 18 May 2021
Title
[4] setBuffer called incorrectly
[4] setBuffer called incorrectly in /libraries/src/Cache/Cache.php
avatar PhilETaylor PhilETaylor - edited - 18 May 2021
avatar Fedik
Fedik - comment - 4 Dec 2021

this code probably doesn't work at all.

This works, there is fallback code in DocumentHTML

public function setBuffer($content, $options = array())
{
// The following code is just for backward compatibility.
if (\func_num_args() > 1 && !\is_array($options))
{
$args = \func_get_args();
$options = array();
$options['type'] = $args[1];
$options['name'] = $args[2] ?? null;
$options['title'] = $args[3] ?? null;
}
parent::$_buffer[$options['type']][$options['name']][$options['title']] = $content;
return $this;
}

But better update that part of course.

avatar PhilETaylor PhilETaylor - close - 6 Mar 2022
avatar PhilETaylor
PhilETaylor - comment - 6 Mar 2022

well nothing to fix - just a strange way to approach b/c :)

avatar PhilETaylor PhilETaylor - change - 6 Mar 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-03-06 23:18:20
Closed_By PhilETaylor
Labels Added: No Code Attached Yet
Removed: ?

Add a Comment

Login with GitHub to post a comment