#46419 [Opn]: Elements of associative arrays with NULL value are lost

From: Date: Wed, 29 Oct 2008 12:49:02 +0000
Subject: #46419 [Opn]: Elements of associative arrays with NULL value are lost
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-130277@lists.php.net to get a copy of this message
ID: 46419 User updated by: max dot bilyk at gmail dot com -Summary: Elements of associative arrays and object properties with NULL value are lost Reported By: max dot bilyk at gmail dot com Status: Open Bug Type: SOAP related Operating System: SuSE SLES 10 PHP Version: 5.2.6 New Comment: Sorry, object properties are OK, so I removed it from "Summary" Previous Comments: ------------------------------------------------------------------------ [2008-10-29 12:47:18] max dot bilyk at gmail dot com Description: ------------ When transferring via SOAP associative arrays which have elements with NULL value these elements are lost. At the same time f.e. empty strings are transferred normally. Properities of objects with NULL value are also transferred OK. The problem is that indices of associative arrays are also informative as well as their values, therefore it's a loss of significant information. Another example: in case of data fetch from database into associative array we often have array elements with NULL value, and when fetching multiple rows each time the structure of array will be different while we expect it to be the same after transfer via SOAP. P.S. This case is in non-WSDL mode. Reproduce code: --------------- ---- SOAP Server --- class foo { function bar() { return array('a' => 1, 'b' => NULL, 'c' => 2, 'd'=>''); } } $server = new SoapServer(null, array('uri' => "http://test-uri/")); $server->setClass("foo"); $server->handle(); ---- SOAP Client --- $client = new SoapClient(NULL, array('location'=> "http://...../server.php", "uri" => "http://test-uri/", "trace" => 1, "exceptions" => 1)); $result = $client->bar(); print_r($result); Expected result: ---------------- array ( 'a' => 1, 'b' => NULL 'c' => 2 'd' => '', ) Actual result: -------------- array ( 'a' => 1, 'c' => 2 'd' => '', ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=46419&edit=1

« previous php.bugs (#130277) next »