diff --git a/cake/libs/set.php b/cake/libs/set.php index e727728ba..7e33a1504 100644 --- a/cake/libs/set.php +++ b/cake/libs/set.php @@ -537,9 +537,9 @@ class Set extends Object { $key = intval($key); } if ($i == count($path) - 1) { - return isset($data[$key]); + return (is_array($data) && array_key_exists($key, $data)); } else { - if (!isset($data[$key])) { + if (!is_array($data) && array_key_exists($key, $data)) { return false; } $data =& $data[$key]; diff --git a/cake/tests/cases/libs/set.test.php b/cake/tests/cases/libs/set.test.php index 40237fa28..f70bf8d10 100644 --- a/cake/tests/cases/libs/set.test.php +++ b/cake/tests/cases/libs/set.test.php @@ -1020,7 +1020,12 @@ class SetTest extends UnitTestCase { $expected = array('Data' => array('Post' => array('title' => 'Title of this post', 'description' => 'cool'))); $this->assertEqual($result, $expected); } - + + function testStrictKeyCheck() { + $set = new Set(array('a' => 'hi')); + $this->assertFalse($set->check('a.b')); + } + function __flatten($results, $key = null) { $stack = array(); foreach ($results as $k => $r) {