diff --git a/lib/Cake/Test/Case/Utility/HashTest.php b/lib/Cake/Test/Case/Utility/HashTest.php index 67adfc9db..ebfa9c520 100644 --- a/lib/Cake/Test/Case/Utility/HashTest.php +++ b/lib/Cake/Test/Case/Utility/HashTest.php @@ -593,6 +593,12 @@ class HashTest extends CakeTestCase { ); $this->assertTrue(Hash::contains($b, $a)); $this->assertFalse(Hash::contains($a, $b)); + + $a = array(0 => 'test', 'string' => null); + $this->assertTrue(Hash::contains($a, array('string' => null))); + + $a = array(0 => 'test', 'string' => null); + $this->assertTrue(Hash::contains($a, array('test'))); } /** diff --git a/lib/Cake/Utility/Hash.php b/lib/Cake/Utility/Hash.php index 8cc99977a..e12f14c5f 100644 --- a/lib/Cake/Utility/Hash.php +++ b/lib/Cake/Utility/Hash.php @@ -442,14 +442,14 @@ class Hash { $val = $needle[$key]; unset($needle[$key]); - if (isset($data[$key]) && is_array($val)) { + if (array_key_exists($key, $data) && is_array($val)) { $next = $data[$key]; unset($data[$key]); if (!empty($val)) { $stack[] = array($val, $next); } - } elseif (!isset($data[$key]) || $data[$key] != $val) { + } elseif (!array_key_exists($key, $data) || $data[$key] != $val) { return false; }