From: Operating system: Linux PHP version: 5.3.6 Package: SimpleXML related Bug Type: Bug Bug description:SimpleXML iteration produces infinite loop
Description: ------------ see the test script. inside the foreach-loop the call of e.g. $nodes->asXml() will reset the iteration to the beginning and therefore the loop will forever remain on the second element. this may be related to bug #50670 and #51846 greets, karl Test script: --------------- $xmlString = "<root><a><b>1</b><b>2</b><b>3</b></a></root>"; $xml = simplexml_load_string($xmlString); $nodes = $xml->a->b; foreach ($nodes as $nodeData) { echo "nodeData: " . $nodeData . "\n"; //the following code will break the iteration on the second element and resets the pointer //happens by any of these methods $xml = $nodes->asXml(); //$nodes->getName(); //$nodes->attributes(); //$nodes->children(); //$nodes->getNamespaces(); //iteration_breaker($nodes); } Expected result: ---------------- nodeData: 1 nodeData: 2 nodeData: 3 Actual result: -------------- nodeData: 1 nodeData: 2 nodeData: 2 nodeData: 2 nodeData: 2 nodeData: 2 nodeData: 2 nodeData: 2 nodeData: 2 nodeData: 2 and so on... -- Edit bug report at https://bugs.php.net/bug.php?id=55098&edit=1 -- Try a snapshot (PHP 5.2): https://bugs.php.net/fix.php?id=55098&r=trysnapshot52 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=55098&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=55098&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=55098&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=55098&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=55098&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=55098&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=55098&r=needscript Try newer version: https://bugs.php.net/fix.php?id=55098&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=55098&r=support Expected behavior: https://bugs.php.net/fix.php?id=55098&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=55098&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=55098&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=55098&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=55098&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=55098&r=dst IIS Stability: https://bugs.php.net/fix.php?id=55098&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=55098&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=55098&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=55098&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=55098&r=mysqlcfg Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=55098&r=trysnapshot54