dmitry          Mon Jan 26 11:20:23 2009 UTC

  Modified files:              
    /php-src/ext/soap   php_encoding.c 
    /php-src/ext/soap/tests/bugs        bug46419.phpt 
  Log:
  Fixed bug #46419 (Elements of associative arrays with NULL value are lost)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/soap/php_encoding.c?r1=1.174&r2=1.175&diff_format=u
Index: php-src/ext/soap/php_encoding.c
diff -u php-src/ext/soap/php_encoding.c:1.174 
php-src/ext/soap/php_encoding.c:1.175
--- php-src/ext/soap/php_encoding.c:1.174       Wed Dec 31 11:12:35 2008
+++ php-src/ext/soap/php_encoding.c     Mon Jan 26 11:20:18 2009
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <dmi...@zend.com>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: php_encoding.c,v 1.174 2008/12/31 11:12:35 sebastian Exp $ */
+/* $Id: php_encoding.c,v 1.175 2009/01/26 11:20:18 dmitry Exp $ */
 
 #include <time.h>
 
@@ -705,7 +705,9 @@
                        soap_error0(E_ERROR, "Encoding: Violation of encoding 
rules");
                }
        } else {
-               ZVAL_EMPTY_STRING(ret);
+               TSRMLS_FETCH();
+
+               soap_decode_string(ret, "" TSRMLS_CC);
        }
        return ret;
 }
@@ -2715,39 +2717,38 @@
                        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);
+                       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();
 
-                                       smart_str_free(&tmp);
+                               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);
                }
        }
http://cvs.php.net/viewvc.cgi/php-src/ext/soap/tests/bugs/bug46419.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/soap/tests/bugs/bug46419.phpt
diff -u /dev/null php-src/ext/soap/tests/bugs/bug46419.phpt:1.2
--- /dev/null   Mon Jan 26 11:20:23 2009
+++ php-src/ext/soap/tests/bugs/bug46419.phpt   Mon Jan 26 11:20:22 2009
@@ -0,0 +1,43 @@
+--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) ""
+}



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to