diff --git a/cake/libs/set.php b/cake/libs/set.php index a2ad13465..8cf170b62 100644 --- a/cake/libs/set.php +++ b/cake/libs/set.php @@ -417,13 +417,16 @@ class Set extends Object { } $match = false; - if (array_key_exists($token, $context['item']) && (!$conditions || Set::matches($conditions, $context['item'][$token], $i))) { + if (array_key_exists($token, $context['item'])) { $items = $context['item'][$token]; if (!is_array($items) || !isset($items[0])) { $items = array($items); } foreach ($items as $item) { + if ($conditions && !Set::matches($conditions, $item, $i)) { + continue; + } $matches[] = array( 'trace' => am($context['trace'], $context['key']), 'key' => $token, diff --git a/cake/tests/cases/libs/set.test.php b/cake/tests/cases/libs/set.test.php index d30866ab9..a5404e98b 100644 --- a/cake/tests/cases/libs/set.test.php +++ b/cake/tests/cases/libs/set.test.php @@ -476,6 +476,10 @@ class SetTest extends UnitTestCase { $r = Set::extract('/Comment/id', $common); $expected = array(1, 2, 3, 4, 5); $this->assertEqual($r, $expected); + + $expected = array(1, 2, 4, 5); + $r = Set::extract('/Comment[id!=3]/id', $common); + $this->assertEqual($r, $expected); } /** * undocumented function