Merge pull request #4575 from HavokInspiration/hash-insert-get-defect

Fix Hash::get() not returning values with special paths
This commit is contained in:
José Lorenzo Rodríguez 2014-09-10 23:22:23 +02:00
commit fb4b79d292
2 changed files with 8 additions and 1 deletions

View file

@ -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'));
}
/**

View file

@ -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') {