mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request #4575 from HavokInspiration/hash-insert-get-defect
Fix Hash::get() not returning values with special paths
This commit is contained in:
commit
fb4b79d292
2 changed files with 8 additions and 1 deletions
|
@ -1367,6 +1367,13 @@ class HashTest extends CakeTestCase {
|
|||
'pages' => array('name' => array()),
|
||||
);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$a = array(
|
||||
'foo' => array('bar' => 'baz')
|
||||
);
|
||||
$result = Hash::insert($a, 'some.0123.path', array('foo' => array('bar' => 'baz')));
|
||||
$expected = array('foo' => array('bar' => 'baz'));
|
||||
$this->assertEquals($expected, Hash::get($result, 'some.0123.path'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -290,7 +290,7 @@ class Hash {
|
|||
$count = count($path);
|
||||
$last = $count - 1;
|
||||
foreach ($path as $i => $key) {
|
||||
if (is_numeric($key) && (int)$key > 0 || $key === '0') {
|
||||
if ((is_numeric($key) && intval($key) > 0 || $key === '0') && strpos($key, '0') !== 0) {
|
||||
$key = (int)$key;
|
||||
}
|
||||
if ($op === 'insert') {
|
||||
|
|
Loading…
Reference in a new issue