Issues

ZF-6600: testConstructorShouldAcceptResourceLoaderInOptions(Zend_Application_Module_BootstrapTest) unit tests failure

Issue Type: Unit Tests: Problem Created: 2009-05-11T01:55:23.000+0000 Last Updated: 2009-05-12T08:06:04.000+0000 Status: Resolved Fix version(s): - 1.8.1 (12/May/09)

Reporter: Alexander Veremyev (alexander) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Application

Related issues: Attachments:

Description

{panel} 1) testConstructorShouldAcceptResourceLoaderInOptions(Zend_Application_Module_BootstrapTest) array_merge_recursive(): recursion detected /home/cawa/ZendFramework/svn/framework/branches/release-1.8/library/Zend/Application/Bootstrap/BootstrapAbstract.php:135 /home/cawa/ZendFramework/svn/framework/branches/release-1.8/library/Zend/Application/Bootstrap/BootstrapAbstract.php:135 /home/cawa/ZendFramework/svn/framework/branches/release-1.8/library/Zend/Application/Module/Bootstrap.php:65 {panel}

Comments

Posted by Alexander Veremyev (alexander) on 2009-05-11T03:43:23.000+0000

The root of the problem is array_merge_recursive() behavior. It processes objects like an arrays and does this in astrange way.

E.g. the following code:

<pre class="highlight">
class A {
    public $a = 1;
}

$a1 = new A();

$ar1 = array('key' => $a1);
$ar2 = array('key' => $a1);

var_dump($ar2);
var_dump(array_merge_recursive($ar1, $ar2));

is processed without errors and gives the following result: {panel} array(1) { ["key"]=> object(A)#1 (1) { ["a"]=> int(1) } } array(1) { ["key"]=> array(1) { ["a"]=> array(2) { [0]=> int(1) [1]=> int(1) } } } {panel}

In the same time

<pre class="highlight">
class A {
    public $a = 1;

    public function __construct() {
        $this->a = 2;
    }
}

$a1 = new A();

$ar1 = array('key' => $a1);
$ar2 = array('key' => $a1);

var_dump($ar2);
var_dump(array_merge_recursive($ar1, $ar2));

gives another result: {panel} array(1) { ["key"]=> object(A)#1 (1) { ["a"]=> int(2) } }

Warning: array_merge_recursive(): recursion detected in /home/cawa/ZendFramework/laboratory/test3.php on line 17 array(1) { ["key"]=> array(1) { ["a"]=> int(2) } } {panel}

array_merge_recursive() has probably be replaced with array_merge or foreach (...) structure

Posted by Matthew Weier O'Phinney (matthew) on 2009-05-11T04:58:36.000+0000

I'm unable to reproduce this behavior; can you test with current updates,please?

Posted by Matthew Weier O'Phinney (matthew) on 2009-05-12T08:06:03.000+0000

I replaced array_merge_recursive with a custom recursive merge in all Zend_App classes that needed it, and I cannot reproduce the error at this point.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts