]> granicus.if.org Git - php/commitdiff
MFH: fix bug #47849 (Non-deep import loses the namespace)
authorRob Richards <rrichards@php.net>
Tue, 7 Apr 2009 15:33:20 +0000 (15:33 +0000)
committerRob Richards <rrichards@php.net>
Tue, 7 Apr 2009 15:33:20 +0000 (15:33 +0000)
add test

ext/dom/document.c
ext/dom/tests/bug47849.phpt [new file with mode: 0644]

index e87879d09db78c8336d0293fa3eabbeeb9b3aade..7cd3101dbf969fb61a49be85d9eefb3e7c85da31 100644 (file)
@@ -1245,6 +1245,9 @@ PHP_FUNCTION(dom_document_import_node)
        if (nodep->doc == docp) {
                retnodep = nodep;
        } else {
+               if ((recursive == 0) && (nodep->type == XML_ELEMENT_NODE)) {
+                       recursive = 2;
+               }
                retnodep = xmlDocCopyNode(nodep, docp, recursive);
                if (!retnodep) {
                        RETURN_FALSE;
diff --git a/ext/dom/tests/bug47849.phpt b/ext/dom/tests/bug47849.phpt
new file mode 100644 (file)
index 0000000..7e6b02c
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+Bug #47849 (Non-deep import loses the namespace).
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php 
+
+$aDOM= new DOMDocument();
+$aDOM->appendChild($aDOM->createElementNS('urn::root','r:root'));
+
+$fromdom= new DOMDocument();
+$fromdom->loadXML('<data xmlns="urn::data">aaa</data>');
+
+$data= $fromdom->documentElement;
+$aDOM->documentElement->appendChild($aDOM->importNode($data));
+
+echo $aDOM->saveXML();
+
+?>
+--EXPECT--
+<?xml version="1.0"?>
+<r:root xmlns:r="urn::root"><data xmlns="urn::data"/></r:root>