Issue Details (XML | Word | Printable)

Key: ZF-6600
Type: Unit Tests: Problem Unit Tests: Problem
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Matthew Weier O'Phinney
Reporter: Alexander Veremyev
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Google issue summary
Zend Framework

testConstructorShouldAcceptResourceLoaderInOptions(Zend_Application_Module_BootstrapTest) unit tests failure

Created: 11/May/09 01:55 AM   Updated: 12/May/09 08:06 AM   Resolved: 12/May/09 08:06 AM
Component/s: Zend_Application
Affects Version/s: None
Fix Version/s: 1.8.1

Time Tracking:
Not Specified

Fix Version Priority: Must Have


 Description  « Hide

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



Alexander Veremyev added a comment - 11/May/09 03:43 AM

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:

array(1) {
["key"]=>
object(A)#1 (1)

Unknown macro: { ["a"]=> int(1) }

}
array(1) {
["key"]=>
array(1) {
["a"]=>
array(2)
Unknown macro: { [0]=> int(1) [1]=> int(1) }

}
}

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:

array(1) {
["key"]=>
object(A)#1 (1)

Unknown macro: { ["a"]=> int(2) }

}

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

}
}

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


Matthew Weier O'Phinney added a comment - 11/May/09 04:58 AM

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


Matthew Weier O'Phinney added a comment - 12/May/09 08:06 AM

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.