Skip to content
Permalink
Browse files

Fix Hash::remove() removing data even if the path is not matched

  • Loading branch information...
HavokInspiration committed Sep 23, 2014
1 parent d715c6f commit b70cb132fd1ac50f429cdc8ce68f0303e40c6051
Showing with 13 additions and 1 deletion.
  1. +12 −0 lib/Cake/Test/Case/Utility/HashTest.php
  2. +1 −1 lib/Cake/Utility/Hash.php
@@ -1488,6 +1488,18 @@ public function testRemove() {
)
);
$this->assertEquals($expected, $result);
$array = array(
0 => 'foo',
1 => array(
0 => 'baz'
)
);
$expected = $array;
$result = Hash::remove($array, '{n}.part');
$this->assertEquals($expected, $result);
$result = Hash::remove($array, '{n}.{n}.part');
$this->assertEquals($expected, $result);
}
/**
@@ -355,7 +355,7 @@ public static function remove(array $data, $path) {
if (empty($data[$k])) {
unset($data[$k]);
}
} elseif ($match) {
} elseif ($match && empty($nextPath)) {
unset($data[$k]);
}
}

0 comments on commit b70cb13

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