diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 22b5fe881..7bc58f024 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -440,17 +440,24 @@ class Controller extends Object { $this->uses = array_flip($this->uses); array_unshift($this->uses, $plugin . $this->modelClass); } - } elseif ($this->uses !== null || $this->uses !== false) { - $this->_mergeVars(array('uses'), 'AppController', false); + } elseif ( + ($this->uses !== null || $this->uses !== false) && + is_array($this->uses) && !empty($appVars['uses']) + ) { + $this->uses = array_merge($this->uses, array_diff($appVars['uses'], $this->uses)); + var_dump($this->uses); } $this->_mergeVars($merge, 'AppController', true); } if ($pluginController && $pluginName != null) { $merge = array('components', 'helpers'); - - if ($this->uses !== null || $this->uses !== false) { - $this->_mergeVars(array('uses'), $pluginController, false); + $appVars = get_class_vars($pluginController); + if ( + ($this->uses !== null || $this->uses !== false) && + is_array($this->uses) && !empty($appVars['uses']) + ) { + $this->uses = array_merge($this->uses, array_diff($appVars['uses'], $this->uses)); } $this->_mergeVars($merge, $pluginController); } diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index a1d06b779..089955373 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -1283,13 +1283,14 @@ class ControllerTest extends CakeTestCase { ? array_merge($appVars['uses'], $testVars['uses']) : $testVars['uses']; - $this->assertEqual(count(array_diff($TestController->helpers, $helpers)), 0); + $this->assertEqual(count(array_diff_key($TestController->helpers, array_flip($helpers))), 0); $this->assertEqual(count(array_diff($TestController->uses, $uses)), 0); $this->assertEqual(count(array_diff_assoc(Set::normalize($TestController->components), Set::normalize($components))), 0); - $TestController = new AnotherTestController($request); $expected = array('ControllerComment', 'ControllerAlias', 'ControllerPost'); - $this->assertEqual($expected, $TestController->uses, '$uses was merged incorrectly, AppController models should be last.'); + $this->assertEquals($expected, $TestController->uses, '$uses was merged incorrectly, AppController models should be last.'); + + $TestController = new AnotherTestController($request); $TestController->constructClasses(); $appVars = get_class_vars('AppController'); diff --git a/cake/tests/cases/libs/view/helpers/number.test.php b/cake/tests/cases/libs/view/helpers/number.test.php index d34eb65c0..30022d2cd 100644 --- a/cake/tests/cases/libs/view/helpers/number.test.php +++ b/cake/tests/cases/libs/view/helpers/number.test.php @@ -18,6 +18,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ App::import('Helper', 'Number'); +App::import('View', 'View'); /** * NumberHelperTest class