Fix null path in Hash::get() causing exceptions.

This was a regression introduced in 2.6.x

Refs #6297
This commit is contained in:
mark_story 2015-04-09 07:50:29 -04:00
parent 4a7344ae80
commit a6aefdd4d3
2 changed files with 4 additions and 2 deletions

View file

@ -247,6 +247,9 @@ class HashTest extends CakeTestCase {
public function testGetNullPath() {
$result = Hash::get(array('one' => 'two'), null, '-');
$this->assertEquals('-', $result);
$result = Hash::get(array('one' => 'two'), '', '-');
$this->assertEquals('-', $result);
}
/**

View file

@ -43,7 +43,7 @@ class Hash {
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::get
*/
public static function get(array $data, $path, $default = null) {
if (empty($data)) {
if (empty($data) || $path === '' || $path === null) {
return $default;
}
if (is_string($path) || is_numeric($path)) {
@ -55,7 +55,6 @@ class Hash {
$path
));
}
$parts = $path;
}