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

This commit is contained in:
Yves 2014-09-23 22:00:49 +02:00
parent d715c6f2de
commit b70cb132fd
2 changed files with 13 additions and 1 deletions

View file

@ -1488,6 +1488,18 @@ class HashTest extends CakeTestCase {
)
);
$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);
}
/**

View file

@ -355,7 +355,7 @@ class Hash {
if (empty($data[$k])) {
unset($data[$k]);
}
} elseif ($match) {
} elseif ($match && empty($nextPath)) {
unset($data[$k]);
}
}