?
avatar jeffchannell
jeffchannell
4 Nov 2015

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.

avatar jeffchannell jeffchannell - open - 4 Nov 2015
avatar zero-24
zero-24 - comment - 4 Nov 2015

@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

avatar zero-24 zero-24 - change - 4 Nov 2015
Labels Added: ?
avatar jeffchannell
jeffchannell - comment - 4 Nov 2015

@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] => .
)
avatar brianteeman
brianteeman - comment - 4 Nov 2015

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

avatar jeffchannell
jeffchannell - comment - 4 Nov 2015

@brianteeman if so, that's great! Do you have a link?

avatar jeffchannell
jeffchannell - comment - 4 Nov 2015

@brianteeman found it:

#7210

Same fix as what I posted above.

avatar brianteeman
brianteeman - comment - 4 Nov 2015

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:

#7210 #7210

Same fix as what I posted above.


Reply to this email directly or view it on GitHub
#8275 (comment).

avatar zero-24 zero-24 - change - 6 Nov 2015
Category Libraries
avatar zero-24 zero-24 - change - 6 Nov 2015
Status New Closed
Closed_Date 0000-00-00 00:00:00 2015-11-06 22:20:11
Closed_By zero-24
avatar zero-24 zero-24 - close - 6 Nov 2015
avatar zero-24 zero-24 - close - 6 Nov 2015
avatar zero-24
zero-24 - comment - 6 Nov 2015

Closing as we have a PR that use that code


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

Add a Comment

Login with GitHub to post a comment