Fixing extraction of non-zero arrays with only one element and attribute selectors. Fixes #475

This commit is contained in:
Mark Story 2010-03-24 23:25:02 -04:00
parent cbb65ca85f
commit 4f4d3f9ffe
2 changed files with 4 additions and 3 deletions

View file

@ -438,7 +438,8 @@ class Set extends Object {
$items = array($items);
} elseif (!isset($items[0])) {
$current = current($items);
if ((is_array($current) && count($items) <= 1) || !is_array($current)) {
$currentKey = key($items);
if (!is_array($current) || (is_array($current) && count($items) <= 1 && !is_numeric($currentKey))) {
$items = array($items);
}
}

View file

@ -1035,10 +1035,10 @@ class SetTest extends CakeTestCase {
$result = Set::extract('/User/id', $nonZero);
$this->assertEqual($result, $expected, 'Failed non zero array key extract');
$startingAtOne = array(
'Article' => array(
1=> array(
1 => array(
'id' => 1,
'approved' => 1,
),