Skip to content

Commit

Permalink
Hash::get() should not throw an exception on '' or null path.
Browse files Browse the repository at this point in the history
Port fixes for #6297 to 3.0. This resolves a regression that was
introduced in 2.6.x.
  • Loading branch information
markstory committed Apr 9, 2015
1 parent d1a17c2 commit fcd51e1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Utility/Hash.php
Expand Up @@ -45,7 +45,7 @@ class Hash
*/
public static function get(array $data, $path, $default = null)
{
if (empty($data)) {
if (empty($data) || $path === null || $path === '') {
return $default;
}

Expand Down
3 changes: 3 additions & 0 deletions tests/TestCase/Utility/HashTest.php
Expand Up @@ -210,6 +210,9 @@ public function testGet()
$result = Hash::get($data, '');
$this->assertNull($result);

$result = Hash::get($data, null, '-');
$this->assertSame('-', $result);

$result = Hash::get($data, '0.Article.title');
$this->assertEquals('First Article', $result);

Expand Down

0 comments on commit fcd51e1

Please sign in to comment.