soap_error0(E_ERROR, "Encoding: Violation of encoding rules");
}
} else {
- ZVAL_EMPTY_STRING(ret);
+ TSRMLS_FETCH();
+
+ soap_decode_string(ret, "" TSRMLS_CC);
}
return ret;
}
ulong int_val;
zend_hash_get_current_data(data->value.ht, (void **)&temp_data);
- if (Z_TYPE_PP(temp_data) != IS_NULL) {
- item = xmlNewNode(NULL, BAD_CAST("item"));
- xmlAddChild(xmlParam, item);
- key = xmlNewNode(NULL, BAD_CAST("key"));
- xmlAddChild(item,key);
- key_type = zend_hash_get_current_key_ex(data->value.ht, &key_val, &key_len, &int_val, FALSE, NULL);
- if (key_type == HASH_KEY_IS_STRING || key_type == HASH_KEY_IS_UNICODE) {
- char *str;
- TSRMLS_FETCH();
-
- if (style == SOAP_ENCODED) {
- set_xsi_type(key, "xsd:string");
- }
- str = soap_encode_string_ex(key_type, key_val, key_len TSRMLS_CC);
- xmlNodeSetContent(key, BAD_CAST(str));
- efree(str);
- } else {
- smart_str tmp = {0};
- smart_str_append_long(&tmp, int_val);
- smart_str_0(&tmp);
-
- if (style == SOAP_ENCODED) {
- set_xsi_type(key, "xsd:int");
- }
- xmlNodeSetContentLen(key, BAD_CAST(tmp.c), tmp.len);
-
- smart_str_free(&tmp);
+ item = xmlNewNode(NULL, BAD_CAST("item"));
+ xmlAddChild(xmlParam, item);
+ key = xmlNewNode(NULL, BAD_CAST("key"));
+ xmlAddChild(item,key);
+ key_type = zend_hash_get_current_key_ex(data->value.ht, &key_val, &key_len, &int_val, FALSE, NULL);
+ if (key_type == HASH_KEY_IS_STRING || key_type == HASH_KEY_IS_UNICODE) {
+ char *str;
+ TSRMLS_FETCH();
+
+ if (style == SOAP_ENCODED) {
+ set_xsi_type(key, "xsd:string");
}
+ str = soap_encode_string_ex(key_type, key_val, key_len TSRMLS_CC);
+ xmlNodeSetContent(key, BAD_CAST(str));
+ efree(str);
+ } else {
+ smart_str tmp = {0};
+ smart_str_append_long(&tmp, int_val);
+ smart_str_0(&tmp);
- xparam = master_to_xml(get_conversion((*temp_data)->type), (*temp_data), style, item);
+ if (style == SOAP_ENCODED) {
+ set_xsi_type(key, "xsd:int");
+ }
+ xmlNodeSetContentLen(key, BAD_CAST(tmp.c), tmp.len);
- xmlNodeSetName(xparam, BAD_CAST("value"));
+ smart_str_free(&tmp);
}
+
+ xparam = master_to_xml(get_conversion((*temp_data)->type), (*temp_data), style, item);
+
+ xmlNodeSetName(xparam, BAD_CAST("value"));
+
zend_hash_move_forward(data->value.ht);
}
}
--- /dev/null
+--TEST--
+Bug #46419 (Elements of associative arrays with NULL value are lost)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+function bar() {
+ return array('a' => 1, 'b' => NULL, 'c' => 2, 'd'=>'');
+}
+
+class LocalSoapClient extends SoapClient {
+
+ function __construct($wsdl, $options) {
+ parent::__construct($wsdl, $options);
+ $this->server = new SoapServer($wsdl, $options);
+ $this->server->addFunction('bar');
+ }
+
+ function __doRequest($request, $location, $action, $version, $one_way = 0) {
+ ob_start();
+ $this->server->handle($request);
+ $response = ob_get_contents();
+ ob_end_clean();
+ return $response;
+ }
+
+}
+
+$x = new LocalSoapClient(NULL,array('location'=>'test://',
+ 'uri'=>'http://testuri.org'));
+var_dump($x->bar());
+?>
+--EXPECT--
+array(4) {
+ [u"a"]=>
+ int(1)
+ [u"b"]=>
+ NULL
+ [u"c"]=>
+ int(2)
+ [u"d"]=>
+ unicode(0) ""
+}