From 2266292594f1a795019982b40b82a6ae15339689 Mon Sep 17 00:00:00 2001 From: dogmatic69 Date: Fri, 14 Dec 2012 22:45:52 +0000 Subject: [PATCH] fixing bug in Hash where array is not similar to the path required --- lib/Cake/Test/Case/Utility/HashTest.php | 3 +++ lib/Cake/Utility/Hash.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/Utility/HashTest.php b/lib/Cake/Test/Case/Utility/HashTest.php index a4bce1bcbef..e404197949d 100644 --- a/lib/Cake/Test/Case/Utility/HashTest.php +++ b/lib/Cake/Test/Case/Utility/HashTest.php @@ -659,6 +659,9 @@ public function testExtractBasic() { $result = Hash::extract($data, '1.Article.title'); $this->assertEquals(array('Second Article'), $result); + + $result = Hash::extract(array(false), '{n}.Something.another_thing'); + $this->assertEquals(array(), $result); } /** diff --git a/lib/Cake/Utility/Hash.php b/lib/Cake/Utility/Hash.php index 584d4160e7a..c99175f895a 100644 --- a/lib/Cake/Utility/Hash.php +++ b/lib/Cake/Utility/Hash.php @@ -117,7 +117,7 @@ public static function extract(array $data, $path) { } foreach ($context[$_key] as $item) { - foreach ($item as $k => $v) { + foreach ((array)$item as $k => $v) { if (self::_matchToken($k, $token)) { $next[] = $v; }