mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request #1004 from dogmatic69/hash-expand-integer-key
Fix issue where Hash::expand() sets incorrect array keys Fixes #3434
This commit is contained in:
commit
6bfbce128f
2 changed files with 13 additions and 1 deletions
|
@ -2163,6 +2163,18 @@ class HashTest extends CakeTestCase {
|
|||
)
|
||||
);
|
||||
$this->assertEquals($result, $expected);
|
||||
|
||||
$data = array('a.b.100.a' => null, 'a.b.200.a' => null);
|
||||
$expected = array(
|
||||
'a' => array(
|
||||
'b' => array(
|
||||
100 => array('a' => null),
|
||||
200 => array('a' => null)
|
||||
)
|
||||
)
|
||||
);
|
||||
$result = Hash::expand($data);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -596,7 +596,7 @@ class Hash {
|
|||
foreach ((array)$arg as $key => $val) {
|
||||
if (!empty($return[$key]) && is_array($return[$key]) && is_array($val)) {
|
||||
$return[$key] = self::merge($return[$key], $val);
|
||||
} elseif (is_int($key)) {
|
||||
} elseif (is_int($key) && isset($return[$key])) {
|
||||
$return[] = $val;
|
||||
} else {
|
||||
$return[$key] = $val;
|
||||
|
|
Loading…
Reference in a new issue