Skip to content
Permalink
Browse files

Fix Hash not returning correct value with special paths

When doing a Hash::insert() with a part of the path starting with a '0', Hash::get() returned null even if the same path was used.
  • Loading branch information...
HavokInspiration committed Sep 10, 2014
1 parent 3a56198 commit 90ad813b40fc6c0f2f844dc65ec851f6b1a73063
Showing with 8 additions and 1 deletion.
  1. +7 −0 lib/Cake/Test/Case/Utility/HashTest.php
  2. +1 −1 lib/Cake/Utility/Hash.php
@@ -1367,6 +1367,13 @@ public function testInsertSimple() {
'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 @@ protected static function _simpleOp($op, $data, $path, $values = null) {
$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') {

0 comments on commit 90ad813

Please sign in to comment.
You can’t perform that action at this time.