summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2016-08-30 10:55:08 +0200
committerNikita Popov <nikic@php.net>2016-08-30 10:56:06 +0200
commit51a564e50557093ec42206301d097dd4f2127acb (patch)
tree5d361472247916bc3627488005a6170139f8767c
parent4a12450de2c0be6b456ef6dca628671b67b0c7a6 (diff)
parent07cc6a6ba2d8cebe2b375353491a26953b250149 (diff)
downloadphp-git-51a564e50557093ec42206301d097dd4f2127acb.tar.gz
Merge branch 'PHP-7.0' into PHP-7.1
-rw-r--r--NEWS3
-rw-r--r--ext/simplexml/simplexml.c4
-rw-r--r--ext/simplexml/tests/bug72971.phpt21
3 files changed, 26 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 5a3a8291d2..c18f87f7d7 100644
--- a/NEWS
+++ b/NEWS
@@ -51,6 +51,9 @@ PHP NEWS
cookie exist). (Yasuo)
. Implemented session_gc() and session_create_id() functions. (Yasuo)
+- SimpleXML:
+ . Fixed bug #72971 (SimpleXML isset/unset do not respect namespace). (Nikita)
+
- Standard:
. Fixed bug #72920 (Accessing a private constant using constant() creates
an exception AND warning). (Laruence)
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c
index 622ff3b6ec..d26f68ee26 100644
--- a/ext/simplexml/simplexml.c
+++ b/ext/simplexml/simplexml.c
@@ -809,7 +809,7 @@ static int sxe_prop_dim_exists(zval *object, zval *member, int check_empty, zend
while (node) {
xmlNodePtr nnext;
nnext = node->next;
- if ((node->type == XML_ELEMENT_NODE) && !xmlStrcmp(node->name, (xmlChar *)Z_STRVAL_P(member))) {
+ if (node->type == XML_ELEMENT_NODE && !xmlStrcmp(node->name, (xmlChar *)Z_STRVAL_P(member)) && match_ns(sxe, node, sxe->iter.nsprefix, sxe->iter.isprefix)) {
break;
}
node = nnext;
@@ -939,7 +939,7 @@ static void sxe_prop_dim_delete(zval *object, zval *member, zend_bool elements,
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)) {
xmlUnlinkNode(node);
php_libxml_node_free_resource(node);
}
diff --git a/ext/simplexml/tests/bug72971.phpt b/ext/simplexml/tests/bug72971.phpt
new file mode 100644
index 0000000000..ff7ded02ef
--- /dev/null
+++ b/ext/simplexml/tests/bug72971.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Bug #72971: SimpleXML isset/unset do not respect namespace
+--SKIPIF--
+<?php if (!extension_loaded("simplexml")) print "skip simplexml extension is not loaded"; ?>
+--FILE--
+<?php
+
+$xml = new SimpleXMLElement('<root xmlns:ns="ns"><foo>bar</foo><ns:foo>ns:bar</ns:foo><ns:foo2>ns:bar2</ns:foo2></root>');
+var_dump(isset($xml->foo2));
+unset($xml->foo);
+var_dump($xml->children('ns'));
+
+?>
+--EXPECT--
+bool(false)
+object(SimpleXMLElement)#2 (2) {
+ ["foo"]=>
+ string(6) "ns:bar"
+ ["foo2"]=>
+ string(7) "ns:bar2"
+}