Update Configure::load() to use Set::merge()

This fixes some of the awkward behavior that using
array_merge_recursive() could create.

Fixes #2441
This commit is contained in:
mark_story 2012-01-07 10:45:35 -05:00
parent 1991430584
commit 87924414fc
4 changed files with 12 additions and 3 deletions

View file

@ -312,7 +312,7 @@ class Configure {
$keys = array_keys($values);
foreach ($keys as $key) {
if (($c = self::read($key)) && is_array($values[$key]) && is_array($c)) {
$values[$key] = array_merge_recursive($c, $values[$key]);
$values[$key] = Set::merge($c, $values[$key]);
}
}
}

View file

@ -224,6 +224,8 @@ class ConfigureTest extends CakeTestCase {
$this->assertEquals('value2', Configure::read('Read'));
$this->assertEquals('buried2', Configure::read('Deep.Second.SecondDeepest'));
$this->assertEquals('buried', Configure::read('Deep.Deeper.Deepest'));
$this->assertEquals('Overwrite', Configure::read('TestAcl.classname'));
$this->assertEquals('one', Configure::read('TestAcl.custom'));
}
/**

View file

@ -5,5 +5,8 @@ $config = array(
'Deeper' => array(
'Deepest' => 'buried'
)
),
'TestAcl' => array(
'classname' => 'Original'
)
);

View file

@ -5,5 +5,9 @@ $config = array(
'Second' => array(
'SecondDeepest' => 'buried2'
)
),
'TestAcl' => array(
'classname' => 'Overwrite',
'custom' => 'one'
)
);