php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32641 foreach($domElement->childNodes AS $child) produces fatal error
Submitted: 2005-04-09 10:55 UTC Modified: 2005-04-09 11:35 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: php dot bug at hebbron dot com Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.0.4 OS: Linux
Private report: No CVE-ID: None
 [2005-04-09 10:55 UTC] php dot bug at hebbron dot com
Description:
------------
The following code works fine on 5.0.2, but causes the fatal error on 5.0.4. Using for($i; $i<$d->documentElement->childNodes->length; $i++){} loop works fine, bt the foreach version is now broken.

Reproduce code:
---------------
$d = new DOMDocument();
$xml = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<root>
	<child></child>
	<child></child>
	<child></child>
	<child></child>
</root>
XML;
$d->loadXML($xml);
foreach($d->documentElement->childNodes AS $child){
	print($child->nodeName."\n");
}

Expected result:
----------------
#text child #text child #text child #text child #text child #text  

Actual result:
--------------
Fatal error: Cannot access undefined property for object with overloaded property access in /home/tom/test/bug_reports/overloaded.php on line 15


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-09 11:34 UTC] php dot bug at hebbron dot com
Apologies: tried again on another machine - I thought I'd disabled the Zend debugger but hadn't. It was the interaction with the debugger that was causing the problem.
 [2005-04-09 11:35 UTC] php dot bug at hebbron dot com
See above - bogus
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Nov 24 04:01:23 2020 UTC