diff options
| author | Rob Richards <rrichards@php.net> | 2009-04-07 15:33:20 +0000 |
|---|---|---|
| committer | Rob Richards <rrichards@php.net> | 2009-04-07 15:33:20 +0000 |
| commit | 8728f276f9a18be53fbe04a02e5d71320281648c (patch) | |
| tree | 0f210f2de080ef0f60e03cb8397e2b8fe6a7a188 | |
| parent | 4399a96a6b17c7c71e8e3ef160b264748bee9085 (diff) | |
| download | php-git-8728f276f9a18be53fbe04a02e5d71320281648c.tar.gz | |
MFH: fix bug #47849 (Non-deep import loses the namespace)
add test
| -rw-r--r-- | ext/dom/document.c | 3 | ||||
| -rw-r--r-- | ext/dom/tests/bug47849.phpt | 22 |
2 files changed, 25 insertions, 0 deletions
diff --git a/ext/dom/document.c b/ext/dom/document.c index e87879d09d..7cd3101dbf 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -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 index 0000000000..7e6b02c8cf --- /dev/null +++ b/ext/dom/tests/bug47849.phpt @@ -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> |
