From:             matthias dot hoseit at comline dot de
Operating system: Windows 2000, Apache 1.3.31
PHP version:      5.0.2
PHP Bug Type:     DOM XML related
Bug description:  serializing a DOMDocument object doesn't work

Description:
------------
The function serialize() doesn't work with a DOMDocument object. After
you've serialized and unserialized an object of DOMDocument the
unserialized object seems to be empty (The object knows that it is a
DOMDocument Object, but all data is lost).

Reproduce code:
---------------
<?PHP
        //----------------------------------------------Building a working
DOMDocument-----------------------------------
        //create new DOMDocument
        $domDoc1 = new DOMDocument();
        //create some elements
        $rootElement = $domDoc1->createElement("Element1");
        $element2 = $domDoc1->createElement("Element2", "Value2");
        //adding element to root
        $rootElement->appendChild($element2);
        //adding root to DOM
        $domDoc1->appendChild($rootElement);
        //show that DOMDocument is working right now
        $elements1 = $domDoc1->getElementsByTagName("Element2");
        foreach ($elements1 as $val) {
                echo "TagName = '".$val->tagName."' ";
                        echo "Value = '".$val->nodeValue."'<br>";
        }
        //----------------------------------------------now the strange
behavior-----------------------------------------
        //now serialize DOMObject
        $serialize1 = serialize($domDoc1);
        //The serialized DOMObject seems to be empty
        echo $serialize1."<br>";
        //unserialize 
        $unserialize1 = unserialize($serialize1);
        //----------------------------------------------the
error--------------------------------------------------------
        //And now there is the error.. $unserialize1 seems to be no DOMDocument
or an empty one
        $elements2 = $unserialize1->getElementsByTagName("Element2");
        //You get the error message: Warning: Couldn't fetch DOMDocument in ....
        //print_r shows an empty object
        print_r($unserialize1);
?>

Expected result:
----------------
I thought, when you unserialize a DOMDocument object you get a DOMDocument
object with all data of the original one (NodeLists etc). 

Actual result:
--------------
After unserializing a serialized DOMDocument object you get an empty
DOMDocument object.

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

Reply via email to