From f6c30745fe20758cb858fdb1289fd89fd2ddd9dc Mon Sep 17 00:00:00 2001 From: the_undefined Date: Wed, 16 Apr 2008 19:12:31 +0000 Subject: [PATCH] Fixes #4485 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6666 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/set.php | 3 +++ cake/tests/cases/libs/set.test.php | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/cake/libs/set.php b/cake/libs/set.php index 82218206d..ce0eae7dd 100644 --- a/cake/libs/set.php +++ b/cake/libs/set.php @@ -384,6 +384,9 @@ class Set extends Object { * @access public */ function extract($path, $data = null, $options = array()) { + if (empty($data) && is_string($path) && $path{0} == '/') { + return array(); + } if (is_string($data) && $data{0} == '/') { $tmp = $path; $path = $data; diff --git a/cake/tests/cases/libs/set.test.php b/cake/tests/cases/libs/set.test.php index ee5fbf878..61e4fc2e7 100644 --- a/cake/tests/cases/libs/set.test.php +++ b/cake/tests/cases/libs/set.test.php @@ -506,6 +506,10 @@ class SetTest extends UnitTestCase { $expected = array($common[0]['Comment'][1]); $r = Set::extract($common, '/Comment[1]/.[2]'); $this->assertEqual($r, $expected); + + $expected = array(); + $r = Set::extract('/User/id', array()); + $this->assertEqual($r, $expected); } /** * undocumented function