Skip to content
Permalink
Browse files

Fixing extraction of non-zero arrays with only one element and attrib…

…ute selectors. Fixes #475
  • Loading branch information...
markstory committed Mar 25, 2010
1 parent cbb65ca commit 4f4d3f9ffe186ed5fde8c1b800903630e66b6113
Showing with 4 additions and 3 deletions.
  1. +2 −1 cake/libs/set.php
  2. +2 −2 cake/tests/cases/libs/set.test.php
@@ -438,7 +438,8 @@ function extract($path, $data = null, $options = array()) {
$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);
}
}
@@ -1035,10 +1035,10 @@ function testExtractWithNonZeroArrays() {
$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,
),

0 comments on commit 4f4d3f9

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.