ZF-6600: testConstructorShouldAcceptResourceLoaderInOptions(Zend_Application_Module_BootstrapTest) unit tests failure

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

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:


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


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

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

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.