Skip to content

Commit

Permalink
Fix looping issue in Component loading.
Browse files Browse the repository at this point in the history
Add failure condition to test suite.

Apple -> Orange -> Banana -> Apple is now the chain
in the testsuite.

Fixes #2168
  • Loading branch information
markstory committed Oct 28, 2011
1 parent adb5be6 commit 7b023bc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cake/libs/controller/component.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,10 @@ function _loadComponents(&$object, $parent = null) {
if (!empty($config)) {
$this->__settings[$component] = $config;
}
}

if (isset($object->{$component}->components) && is_array($object->{$component}->components) && (!isset($object->{$component}->{$parent}))) {
$this->_loadComponents($object->{$component}, $component);
if (isset($object->{$component}->components) && is_array($object->{$component}->components) && (!isset($object->{$component}->{$parent}))) {
$this->_loadComponents($object->{$component}, $component);
}
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions cake/tests/cases/libs/controller/component.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,14 @@ class BananaComponent extends Object {
*/
var $testField = 'BananaField';

/**
* components property
*
* @var array
* @access public
*/
var $components = array('Apple');

/**
* startup method
*
Expand Down

0 comments on commit 7b023bc

Please sign in to comment.