#36226 [Csd]: Inconsistent handling when passing potential arrays.

From: Date: Thu, 08 Feb 2007 15:32:20 +0000
Subject: #36226 [Csd]: Inconsistent handling when passing potential arrays.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-108585@lists.php.net to get a copy of this message
ID: 36226 Updated by: lsmith@php.net Reported By: say_ten at multiplay dot co dot uk Status: Closed Bug Type: SOAP related Operating System: FreeBSD 6.0-p4 PHP Version: 5.1.2 Assigned To: dmitry New Comment: Enabling this feature seems to result in giving me an array(null) if I have a nill'ed sequence. Not sure if this is why you originally introduced the feature of not returning single element sequences as array's, but I was hoping to get an empty array in the above case. Previous Comments: ------------------------------------------------------------------------ [2006-02-02 12:42:40] dmitry@php.net This is not a bug but feature. I stayed the default behavior unchanged, but added ability to create arrays even if only one element exists. To create arrays with single element, you should use special option in SoapServer/SoapClient constructor. $x = new SoapClient($wsdl, array('features' => SOAP_SINGLE_ELEMENT_ARRAYS)); Fixed in CVS HEAD and PHP_5_1. ------------------------------------------------------------------------ [2006-01-31 15:45:34] tony2001@php.net Assigned to the maintainer. ------------------------------------------------------------------------ [2006-01-31 13:24:23] say_ten at multiplay dot co dot uk Description: ------------ When using the following WSDL reponse the server is allowed to return 0 to many recipes. <xsd:complexType name="getRecipesResponse_t"> <xsd:sequence> <xsd:element name="recipes" type="types:Recipe" minOccurs="0" maxOccurs="unbounded" /> </xsd:sequence> </xsd:complexType> The code returned from the function would be of the type: array( array( "id" => 3, "recipe" => cake, "description" => "desc" ) ); If their is only 1 recipe the client returns a standard object of the recipe. If there's more than one, the client returns an array of recipes. This inconsitency results in code to detect and wrap the std class into an array for compatibility with the following code, foreach() for example. This is also true when passing arrays of arrays to the SOAP server. Expected result: ---------------- I would expect the single element arrays passed in to remain single element arrays at the other end. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=36226&edit=1

« previous php.bugs (#108585) next »