In libraries/cms/captcha/captcha.php JCaptcha is incorrectly setting the plugin parameters, making it impossible to render more than one captcha on a single page.
JCaptcha::_load first fetches the plugin:
$plugin = JPluginHelper::getPlugin('captcha', $this->_name);
Then it sets the parameters:
$params = new Registry($plugin->params);
$plugin->params = $params;
Initially, $plugin->params is a JSON encoded string so the first run will load this into Registry and everything works as expected. The issue is that any subsequent runs of this code will result in the existing Registry being loaded into a new Registry, which leads to nested data.
This particular issue can be fixed by checking the parameters before setting them:
if (!($plugin->params instanceof Registry))
{
$params = new Registry($plugin->params);
$plugin->params = $params;
}
However, it may be that this bug is actually in Registry itself and this is just one area that it is manifested.
Labels |
Added:
?
|
@zero-24 I'm not sure my patch is much more than a bandage, as it may be an issue with Registry:
use Joomla\Registry\Registry;
// test data
$json = json_encode(array('foo' => 'bar'));
// first run
$test1 = new Registry($json);
print_r($test1);
// second run
$test2 = new Registry($test1);
print_r($test2);
// third run
$test3 = new Registry($test2);
print_r($test3);
Output:
Joomla\Registry\Registry Object
(
[data:protected] => stdClass Object
(
[foo] => bar
)
[separator] => .
)
Joomla\Registry\Registry Object
(
[data:protected] => stdClass Object
(
[data] => stdClass Object
(
[foo] => bar
)
[separator] => .
)
[separator] => .
)
Joomla\Registry\Registry Object
(
[data:protected] => stdClass Object
(
[data] => stdClass Object
(
[data] => stdClass Object
(
[foo] => bar
)
[separator] => .
)
[separator] => .
)
[separator] => .
)
I thought we already had a pull for this?
On 4 Nov 2015 4:57 pm, "jeffchannell" notifications@github.com wrote:
@zero-24 https://github.com/zero-24 I'm not sure my patch is much more
than a bandage, as it may be an issue with Registry:use Joomla\Registry\Registry;
// test data
$json = json_encode(array('foo' => 'bar'));
// first run
$test1 = new Registry($json);
print_r($test1);
// second run
$test2 = new Registry($test1);
print_r($test2);
// third run
$test3 = new Registry($test2);
print_r($test3);Output:
Joomla\Registry\Registry Object
(
[data:protected] => stdClass Object
(
[foo] => bar
)[separator] => .
)
Joomla\Registry\Registry Object
(
[data:protected] => stdClass Object
(
[data] => stdClass Object
(
[foo] => bar
)[separator] => . ) [separator] => .
)
Joomla\Registry\Registry Object
(
[data:protected] => stdClass Object
(
[data] => stdClass Object
(
[data] => stdClass Object
(
[foo] => bar
)[separator] => . ) [separator] => . ) [separator] => .
)
—
Reply to this email directly or view it on GitHub
#8275 (comment).
@brianteeman if so, that's great! Do you have a link?
My memory rocks despite the old age
On 4 Nov 2015 5:01 pm, "jeffchannell" notifications@github.com wrote:
@brianteeman https://github.com/brianteeman found it:
Same fix as what I posted above.
—
Reply to this email directly or view it on GitHub
#8275 (comment).
Category | ⇒ | Libraries |
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2015-11-06 22:20:11 |
Closed_By | ⇒ | zero-24 |
Closing as we have a PR that use that code
@jeffchannell can you send your fix as pull request against the staging branch? If you need help please see: https://docs.joomla.org/Using_the_Github_UI_to_Make_Pull_Requests