diff --git a/NEWS b/NEWS
index fa975caa262..7d32208695a 100644
--- a/NEWS
+++ b/NEWS
@@ -60,6 +60,7 @@ PHP NEWS
SimpleXMLElement). (Nikita)
- SOAP:
+ . Fixed bug #71711 (Soap Server Member variables reference bug). (Nikita)
. Fixed bug #71996 (Using references in arrays doesn't work like expected).
(Nikita)
diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c
index 58eaeea6663..a8f28fbf1ec 100644
--- a/ext/soap/php_encoding.c
+++ b/ext/soap/php_encoding.c
@@ -1958,7 +1958,7 @@ static xmlNodePtr to_xml_object(encodeTypePtr type, zval *data, int style, xmlNo
xmlNodePtr property;
ZEND_HASH_FOREACH_STR_KEY_VAL_IND(prop, str_key, zprop) {
-
+ ZVAL_DEREF(zprop);
property = master_to_xml(get_conversion(Z_TYPE_P(zprop)), zprop, style, xmlParam);
if (str_key) {
@@ -2679,7 +2679,6 @@ static xmlNodePtr to_xml_map(encodeTypePtr type, zval *data, int style, xmlNodeP
if (Z_TYPE_P(data) == IS_ARRAY) {
ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL_P(data), int_val, key_val, temp_data) {
-
item = xmlNewNode(NULL, BAD_CAST("item"));
xmlAddChild(xmlParam, item);
key = xmlNewNode(NULL, BAD_CAST("key"));
@@ -2702,6 +2701,7 @@ static xmlNodePtr to_xml_map(encodeTypePtr type, zval *data, int style, xmlNodeP
smart_str_free(&tmp);
}
+ ZVAL_DEREF(temp_data);
xparam = master_to_xml(get_conversion(Z_TYPE_P(temp_data)), temp_data, style, item);
xmlNodeSetName(xparam, BAD_CAST("value"));
} ZEND_HASH_FOREACH_END();
diff --git a/ext/soap/tests/bug71711.phpt b/ext/soap/tests/bug71711.phpt
new file mode 100644
index 00000000000..ec3930c6a50
--- /dev/null
+++ b/ext/soap/tests/bug71711.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #71711: Soap Server Member variables reference bug
+--SKIPIF--
+
+--FILE--
+ '', 'uri' => 'http://example.org']) extends SoapClient {
+ public function __doRequest($request, $location, $action, $version, $one_way = 0) {
+ echo $request;
+ return '';
+ }
+};
+$ref = array("foo");
+$data = new stdClass;
+$data->prop =& $ref;
+$client->foo($data);
+
+?>
+--EXPECT--
+
+- foo
diff --git a/ext/soap/tests/bug71996.phpt b/ext/soap/tests/bug71996.phpt
index c4bb092b22b..9f341fbc5e9 100644
--- a/ext/soap/tests/bug71996.phpt
+++ b/ext/soap/tests/bug71996.phpt
@@ -7,15 +7,23 @@ Bug #71996: Using references in arrays doesn't work like expected
$client = new class(null, ['location' => '', 'uri' => 'http://example.org']) extends SoapClient {
public function __doRequest($request, $location, $action, $version, $one_way = 0) {
- echo $request;
+ echo $request, "\n";
return '';
}
};
+
$ref = array("foo");
$data = array(&$ref);
$client->foo($data);
+$ref = array("def" => "foo");
+$data = array("abc" => &$ref);
+$client->foo($data);
+
?>
--EXPECT--
- foo
+
+
+- abc
- deffoo