#46143 [NEW]: Serializing SimpleXML removes the root node; asXML on unserailized breaks

From: Date: Sun, 21 Sep 2008 11:37:24 +0000
Subject: #46143 [NEW]: Serializing SimpleXML removes the root node; asXML on unserailized breaks
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-129151@lists.php.net to get a copy of this message
From: firehed at gmail dot com Operating system: OS X 10.5 PHP version: 5.2.6 PHP Bug Type: SimpleXML related Bug description: Serializing SimpleXML removes the root node; asXML on unserailized breaks Description: ------------ If you serialize a SimpleXMLElement object, the root-level node is lost, causing the unserialize() event to issue a warning-level error (and creating an empty SimpleXMLElement object) and cause most other SimpleXMLElement methods to fail with a warning-level error. Reproduce code: --------------- <?php $xml = new SimpleXMLElement('<test><foo>1</foo><bar>2</bar></test>'); $serialized = serialize($xml); $unserialized = unserialize($serialized); $unserialized->addChild('testing', 'worked'); echo $unserialized->asXML(); Expected result: ---------------- <?xml version="1.0"?> <test><foo>1</foo><bar>2</bar><testing>worked</testing></test> Actual result: -------------- Warning: unserialize() [function.unserialize]: Node no longer exists in /Applications/MAMP/htdocs/serialxml.php on line 4 Warning: SimpleXMLElement::addChild() [function.SimpleXMLElement-addChild]: Node no longer exists in /Applications/MAMP/htdocs/serialxml.php on line 5 Warning: SimpleXMLElement::addChild() [function.SimpleXMLElement-addChild]: Cannot add child. Parent is not a permanent member of the XML tree in /Applications/MAMP/htdocs/serialxml.php on line 5 Warning: SimpleXMLElement::asXML() [function.SimpleXMLElement-asXML]: Node no longer exists in /Applications/MAMP/htdocs/serialxml.php on line 6 -- Edit bug report at http://bugs.php.net/?id=46143&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46143&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46143&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46143&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=46143&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=46143&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=46143&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=46143&r=needscript Try newer version: http://bugs.php.net/fix.php?id=46143&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=46143&r=support Expected behavior: http://bugs.php.net/fix.php?id=46143&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=46143&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=46143&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=46143&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46143&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=46143&r=dst IIS Stability: http://bugs.php.net/fix.php?id=46143&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=46143&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=46143&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=46143&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=46143&r=mysqlcfg

« previous php.bugs (#129151) next »