From: Nikita Popov Date: Tue, 30 Aug 2016 10:43:41 +0000 (+0200) Subject: Followup for bug #72971 X-Git-Tag: php-7.1.0RC1~17^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6adb7e0b7a1d57407f5267293b8b8d63f74b60a7;p=php Followup for bug #72971 Property writes did not respect the namespace either. This is an incomplete fix in that it only handles the case where an existing child element is modified, not when a new one is created. --- diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 7c1e68787c..1f70ddd684 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -607,7 +607,7 @@ long_dim: while (node) { SKIP_TEXT(node); - if (!xmlStrcmp(node->name, (xmlChar *)Z_STRVAL_P(member))) { + if (!xmlStrcmp(node->name, (xmlChar *)Z_STRVAL_P(member)) && match_ns(sxe, node, sxe->iter.nsprefix, sxe->iter.isprefix)) { newnode = node; ++counter; } diff --git a/ext/simplexml/tests/bug72971_2.phpt b/ext/simplexml/tests/bug72971_2.phpt new file mode 100644 index 0000000000..aa6e09438c --- /dev/null +++ b/ext/simplexml/tests/bug72971_2.phpt @@ -0,0 +1,35 @@ +--TEST-- +Bug #72971 (2): SimpleXML property write does not respect namespace +--SKIPIF-- + +--FILE-- +barns:bar'); + +$xml->foo = 'new-bar'; +var_dump($xml->foo); +var_dump($xml->children('ns')->foo); + +$xml->children('ns')->foo = 'ns:new-bar'; +var_dump($xml->foo); +var_dump($xml->children('ns')->foo); + +?> +--EXPECT-- +object(SimpleXMLElement)#2 (1) { + [0]=> + string(7) "new-bar" +} +object(SimpleXMLElement)#3 (1) { + [0]=> + string(6) "ns:bar" +} +object(SimpleXMLElement)#3 (1) { + [0]=> + string(7) "new-bar" +} +object(SimpleXMLElement)#2 (1) { + [0]=> + string(10) "ns:new-bar" +}