#6043: Set::extract XPath Parent Selection causes "Undefined offset" when the
array contains more than 1 element
---------------------------+------------------------------------------------
Reporter: datac0re | Type: Bug
Status: new | Priority: Medium
Milestone: 1.2.x.x | Component: Core Libs
Version: 1.2 Final | Severity: Major
Keywords: | Php_version: n/a
Cake_version: 1.2.0.7962 |
---------------------------+------------------------------------------------
When trying to use XPath to extract parent elements, Set::extract
successfully pulls out the parent element as long as there is only 1
element in the source array. Adding more elements to the array causes an
"Undefined offset on line 415" notice for every element in the array after
the first. Example:
{{{
$x = array();
$x[] = array('CallType' => array('name' => 'Internal Voice'), 'x' =>
array('hour' => 7));
pr(Set::extract('/CallType[name=Internal Voice]/../x/hour', $x));
Prints (correctly):
Array
(
[0] => 7
)
Now when I add more elements:
$x = array();
$x[] = array('CallType' => array('name' => 'Internal Voice'), 'x' =>
array('hour' => 7));
$x[] = array('CallType' => array('name' => 'Internal Voice'), 'x' =>
array('hour' => 2));
$x[] = array('CallType' => array('name' => 'Internal Voice'), 'x' =>
array('hour' => 1));
pr(Set::extract('/CallType[name=Internal Voice]/../x/hour', $x));
Prints (incorrectly):
Notice (8): Undefined offset: 1 [CORE/cake/libs/set.php, line 415]
Notice (8): Undefined offset: 2 [CORE/cake/libs/set.php, line 415]
Array
(
[0] => 7
)
}}}
Only the first element gets added to the final array. The rest of the
elements cause the notices.
--
Ticket URL: <https://trac.cakephp.org/ticket/6043>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC.
Our primary goal is to provide a structured framework that enables PHP users at
all levels to rapidly develop robust web applications, without any loss to
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"tickets cakephp" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---