Permalink
Browse files

Fix looping issue in Component loading.

Add failure condition to test suite.

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

Fixes #2168
  • Loading branch information...
1 parent adb5be6 commit 7b023bca12118f387e2b38454b2b148691c5a0f7 @markstory markstory committed Oct 28, 2011
Showing with 11 additions and 3 deletions.
  1. +3 −3 cake/libs/controller/component.php
  2. +8 −0 cake/tests/cases/libs/controller/component.test.php
View
6 cake/libs/controller/component.php
@@ -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);
+ }
}
}
}
View
8 cake/tests/cases/libs/controller/component.test.php
@@ -228,6 +228,14 @@ class BananaComponent extends Object {
var $testField = 'BananaField';
/**
+ * components property
+ *
+ * @var array
+ * @access public
+ */
+ var $components = array('Apple');
+
+/**
* startup method
*
* @param Controller $controller

0 comments on commit 7b023bc

Please sign in to comment.