php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32104 foreach on $dom->documentElement->childNode causes strange error
Submitted: 2005-02-25 11:44 UTC Modified: 2005-03-02 13:36 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: ppetermann at vivaplus dot tv Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5CVS-2005-02-25 (dev) OS: tested on Linux and Solaris
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ppetermann at vivaplus dot tv
New email:
PHP Version: OS:

 

 [2005-02-25 11:44 UTC] ppetermann at vivaplus dot tv
Description:
------------
doing a foreach loop on:
$dom->documentElement->childNode
causes an Fatal Error:

Fatal error: Cannot access undefined property for object with overloaded property access in FILE on line LINENUMBEROFFOREACH

this didnt happen in PHP5 <= 5.0.3

Reproduce code:
---------------
<?php
$dom = new DomDocument();
$dom->load("xmlfile.xml);
foreach($dom->documentElement->childNode as $node)
{ 
    echo "foo\n";
}
?>

Expected result:
----------------
a foo\n for each childnode of the document element

Actual result:
--------------
Fatal error: Cannot access undefined property for object with overloaded property access in /foo/bar/myfile.php on line 4

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-25 15:01 UTC] rrichards@php.net
sure you are using the latest snapshot?

using your code I get (both with latest 5_0 and HEAD):
Warning: Invalid argument supplied for foreach() in N:\CVS Projects\php5_0\Debug_TS\bug32104.php on line 4

using ->childNodes (which is correct) works fine
 [2005-02-25 15:08 UTC] ppetermann at vivaplus dot tv
hi,

php5-STABLE-200502250930 is the snapshot i used,
well, the missing s was an error in my report, in my code its with the s (as i said its working on php 5.0.3 (in production)
 [2005-02-25 20:39 UTC] rrichards@php.net
still cannot reproduce and this time on a fresh linux box.
can you try rebuilding your php (making sure to clean it first) and if still doesnt work post a link to you phpinfo.
 [2005-03-02 10:43 UTC] ppetermann at vivaplus dot tv
Those where fresh builds of php5, anyways tried it with rebuilding, as expected: didnt change anything.

cant give you a link to the phpinfo since our developement environment aint reachable from the net, but you may use the copy ive put at http://disasta.devedge.info/stuff/phpinfo.htm

best regards,
Peter
 [2005-03-02 13:36 UTC] rrichards@php.net
Do not file bugs when you have Zend extensions (zend_extension=)
loaded. Examples are Zend Optimizer, Zend Debugger, Turck MM Cache,
APC, Xdebug and ionCube loader.  These extensions often modify engine
behavior which is not related to PHP itself.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 10:01:33 2025 UTC