Details
-
Bug
-
Resolution: Fixed
-
Medium
-
3.7.5
-
None
-
Version: 3.7.5
PHP Version: 4.4.2
Webserver: Apache 1.3
Database: MySQL
Description
There is a bug in eZDOMNode::elementByAttributeValue that makes it destroy the last element in the Children array when there are no matches.
I was trying to build an XML document without duplicate elements, but ended up with an error message:
Fatal error: Call to a member function on a non-object in /var/www/vhosts/arkivplan/html/lib/ezxml/classes/ezdomnode.php on line 429
Code to reproduce:
require_once('lib/ezxml/classes/ezxml.php');
$doc=&new eZDOMDocument('Document');
$node=&$doc->createElementNode('RootNode');
$doc->setRoot($node);
foreach(array('A','B','C') as $attrib) {
if ($node->elementByAttributeValue('attr',$attrib)===false)
}
This will cause the abovementioned error on the third iteration.
The problem is that the function loops through the children by reference, then when no element is found, the same variable is set to false(not by reference), thus overwriting the value in the array. My simplest solution is to use a different variable name, see attached patch.
Attachments
Issue Links
- duplicates
-
EZP-10188 Fatal error in ezdomnode: import package
- Closed