mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixing Session from being added to components array twice.
Fixing greedy mergeVars with AppController. Tests Added Fixes #6091 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8024 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
2fc177869e
commit
e045e6826a
4 changed files with 28 additions and 2 deletions
|
@ -74,7 +74,7 @@ class Component extends Object {
|
|||
'base' => $controller->base
|
||||
);
|
||||
|
||||
if (!in_array('Session', $controller->components)) {
|
||||
if (!in_array('Session', $controller->components) && !array_key_exists('Session', $controller->components)) {
|
||||
array_unshift($controller->components, 'Session');
|
||||
}
|
||||
$this->_loadComponents($controller);
|
||||
|
|
|
@ -375,7 +375,7 @@ class Controller extends Object {
|
|||
}
|
||||
}
|
||||
|
||||
if ($pluginController) {
|
||||
if ($pluginController && $pluginName != null) {
|
||||
$appVars = get_class_vars($pluginController);
|
||||
$uses = $appVars['uses'];
|
||||
$merge = array('components', 'helpers');
|
||||
|
|
|
@ -443,6 +443,19 @@ class ComponentTest extends CakeTestCase {
|
|||
'ComponentTestController'
|
||||
));
|
||||
}
|
||||
/**
|
||||
* test that SessionComponent doesn't get added if its already in the components array.
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function testDoubleLoadingOfSessionComponent() {
|
||||
$Controller =& new ComponentTestController();
|
||||
$Controller->uses = array();
|
||||
$Controller->components = array('Session');
|
||||
$Controller->constructClasses();
|
||||
|
||||
$this->assertEqual($Controller->components, array('Session' => '', 'Orange' => array('colour' => 'blood orange')));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -851,7 +851,20 @@ class ControllerTest extends CakeTestCase {
|
|||
|
||||
$this->assertTrue(isset($TestController->ControllerPost));
|
||||
$this->assertTrue(isset($TestController->ControllerComment));
|
||||
}
|
||||
/**
|
||||
* Ensure that __mergeVars is not being greedy and merging with
|
||||
* AppController when you make an instance of Controller
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function testMergeVarsNotGreedy() {
|
||||
$Controller =& new Controller();
|
||||
$Controller->components = array();
|
||||
$Controller->uses = array();
|
||||
$Controller->constructClasses();
|
||||
|
||||
$this->assertEqual($Controller->components, array('Session'));
|
||||
}
|
||||
/**
|
||||
* testReferer method
|
||||
|
|
Loading…
Reference in a new issue