php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24945 foreach on simplexml_element loops forever
Submitted: 2003-08-04 23:27 UTC Modified: 2003-11-06 15:54 UTC
From: tater at potatoe dot com Assigned: sterling (profile)
Status: Closed Package: XML related
PHP Version: 5CVS-2003-08-10 (dev) OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tater at potatoe dot com
New email:
PHP Version: OS:

 

 [2003-08-04 23:27 UTC] tater at potatoe dot com
Description:
------------
I don't even know if this is supposed to work yet or not.
May also be related to #24392 issues.
Doing foreach($xmlobject as $property => $value)
goes into an infinite loop. I tried it on a
stdClass object and it worked OK.

Oh and it segfaults when i bail with a user_error()
but who knows if that's related...

Reproduce code:
---------------
$xml = simplexml_load_string('<outer><inner>4</inner></outer>');
var_dump($xml);
$bound = 0;
foreach ($xml as $p => $v)
{
        var_dump($p,$v);
        if (++$bound > 5)
                user_error("Yikes!", E_USER_ERROR);
}

Expected result:
----------------
object(simplexml_element)#1 (1) {
  ["inner"]=>
  string(1) "4"
}
string(5) "inner"
string(1) "4"

Actual result:
--------------
object(simplexml_element)#1 (1) {
  ["inner"]=>
  string(1) "4"
}
string(5) "inner"
string(1) "4"
string(5) "inner"
string(1) "4"
string(5) "inner"
string(1) "4"
string(5) "inner"
string(1) "4"
string(5) "inner"
string(1) "4"
string(5) "inner"
string(1) "4"

Fatal error: Yikes! in /usr/local/book/apache/htdocs/cvsbook/php5/bugs/simplexml/test.php on line 9
Segmentation fault

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-06 15:54 UTC] helly@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 02:01:30 2024 UTC