From:             frank at cleverbridge dot com
Operating system: Linux 2.6.12-1.1381_FC3 i686 ath
PHP version:      5.1.3
PHP Bug Type:     *XML functions
Bug description:  cloning Dom Documents or Nodes does not work

Description:
------------
Since 5.1.3 you cannot copy a dom object. References still work. The
implementation of the xml extension seam to have changed.

Reproduce code:
---------------
Since 5.1.3 the following code does not work anymore:

<?php

$dom1 = new DomDocument('1.0', 'UTF-8');

$xml = '<foo />';
$dom1->loadXml($xml);

print "<xmp>\n".$dom1->saveXML()."</xmp>\n";

$node = clone $dom1->documentElement;

$dom2 = new DomDocument('1.0', 'UTF-8');
$dom2->appendChild($dom2->importNode($node->cloneNode(true), TRUE));

print "<xmp>\n".$dom2->saveXML()."</xmp>\n";

$dom3 = clone $dom1;

print "<xmp>\n".$dom3->saveXML()."</xmp>\n";

?>

Expected result:
----------------
<?xml version="1.0"?>
<foo/>

<?xml version="1.0"?>
<foo/>

<?xml version="1.0"?>
<foo/>


Actual result:
--------------
&lt;?xml version="1.0"?&gt; &lt;foo/&gt;
Warning: DOMNode::cloneNode() [function.DOMNode-cloneNode]: Couldn't fetch
DOMElement in /www/content/
spielzeug/xslt/513.php on line 13

Warning: DOMDocument::importNode() expects parameter 1 to be DOMNode, null
given in /www/content/
spielzeug/xslt/513.php on line 13

Warning: DOMNode::appendChild() expects parameter 1 to be DOMNode, null
given in /www/content/
spielzeug/xslt/513.php on line 13
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
Warning: DOMDocument::saveXML() [function.DOMDocument-saveXML]: Couldn't
fetch DOMDocument in /www/content/
spielzeug/xslt/513.php on line 19

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

Reply via email to