mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Fixing extraction of non-zero arrays with only one element and attribute selectors. Fixes #475
This commit is contained in:
parent
cbb65ca85f
commit
4f4d3f9ffe
2 changed files with 4 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
),
|
||||
|
|
Loading…
Add table
Reference in a new issue