From:             tater at potatoe dot com
Operating system: OS X 10.2
PHP version:      5CVS-2003-08-04 (dev)
PHP Bug Type:     XML related
Bug description:  foreach on simplexml_element loops forever

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

-- 
Edit bug report at http://bugs.php.net/?id=24945&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=24945&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=24945&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=24945&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=24945&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=24945&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=24945&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=24945&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=24945&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=24945&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=24945&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=24945&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24945&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=24945&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=24945&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=24945&r=gnused

Reply via email to