From: Dmitry Stogov Date: Tue, 20 Mar 2007 07:51:32 +0000 (+0000) Subject: Fixed bug #36226 (Inconsistent handling when passing nillable arrays) X-Git-Tag: php-5.2.2RC1~120 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ef06bfa3ec23b456dc57e47c6542988c44d8e958;p=php Fixed bug #36226 (Inconsistent handling when passing nillable arrays) --- diff --git a/NEWS b/NEWS index c4b78b51f5..3165bd1a4e 100644 --- a/NEWS +++ b/NEWS @@ -104,6 +104,8 @@ PHP NEWS - Fixed bug #38406 (crash when assigning objects to SimpleXML attributes). (Tony) - Fixed bug #37799 (ftp_ssl_connect() falls back to non-ssl connection). (Nuno) - Fixed bug #36496 (SSL support in imap_open() not working on Windows). (Edin) +- Fixed bug #36226 (Inconsistent handling when passing nillable arrays). + (Dmitry) - Fixed bug #35872 (Avoid crash caused by object store being referenced during RSHUTDOWN) (Andy) - Fixed bug #34794 (proc_close() hangs when used with two processes). (jdolecek at netbsd dot org, Nuno) diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c index 53b7fa1f3f..83dd51c645 100644 --- a/ext/soap/php_encoding.c +++ b/ext/soap/php_encoding.c @@ -1221,7 +1221,8 @@ static void model_to_zval_object(zval *ret, sdlContentModelPtr model, xmlNodePtr add_next_index_zval(array, val); } while ((node = get_node(node->next, model->u.element->name)) != NULL); val = array; - } else if ((SOAP_GLOBAL(features) & SOAP_SINGLE_ELEMENT_ARRAYS) && + } else if ((Z_TYPE_P(val) != IS_NULL || !model->u.element->nillable) && + (SOAP_GLOBAL(features) & SOAP_SINGLE_ELEMENT_ARRAYS) && (model->max_occurs == -1 || model->max_occurs > 1)) { zval *array; diff --git a/ext/soap/tests/bugs/bug36226-2.phpt b/ext/soap/tests/bugs/bug36226-2.phpt new file mode 100755 index 0000000000..5479ae9d10 --- /dev/null +++ b/ext/soap/tests/bugs/bug36226-2.phpt @@ -0,0 +1,121 @@ +--TEST-- +Bug #36226 (Inconsistent handling when passing nillable arrays) +--INI-- +soap.wsdl_cache_enabled=0 +--FILE-- +server = new SoapServer($wsdl, $options); + $this->server->addFunction('PostEvents'); + } + + function __doRequest($request, $location, $action, $version) { + echo "$request\n"; + $this->server->handle($request); + return $response; + } +} + +$soapClient = new TestSoapClient($wsdl, + array( + 'trace' => 1, + 'exceptions' => 0, + 'classmap' => array( + 'logOnEvent' => 'LogOnEvent', + 'logOffEvent' => 'LogOffEvent', + 'events' => 'IVREvents' + ), + 'features' => SOAP_SINGLE_ELEMENT_ARRAYS + )); + +$logOnEvent = null; +//$logOnEvent = array(); +$logOffEvents[] = new LogOffEvent(34567, $timestamp, "Smoked"); +//$logOffEvents[] = new LogOffEvent(34568, $timestamp, "SmokeFree"); +$ivrEvents = new IVREvents("1.0", 101, 12345, 'IVR', $logOnEvent, $logOffEvents); +$result = $soapClient->PostEvents($ivrEvents); + +class LogOffEvent { + public $audienceMemberId; + public $timestamp; + public $smokeStatus; + public $callInitiator; + + function __construct($audienceMemberId, $timestamp, $smokeStatus) { + $this->audienceMemberId = $audienceMemberId; + $this->timestamp = $timestamp; + $this->smokeStatus = $smokeStatus; + $this->callInitiator = "IVR"; + } +} + +class LogOnEvent { + public $audienceMemberId; + public $timestamp; + + function __construct($audienceMemberId, $timestamp) { + $this->audienceMemberId = $audienceMemberId; + $this->timestamp = $timestamp; + } +} + +class IVREvents { + public $version; + public $activityId; + public $messageId; + public $source; + public $logOnEvent; + public $logOffEvent; + + function __construct($version, $activityId, $messageId, $source, $logOnEvent=NULL, $logOffEvent=NULL) { + $this->version = $version; + $this->activityId = $activityId; + $this->messageId = $messageId; + $this->source = $source; + $this->logOnEvent = $logOnEvent; + $this->logOffEvent = $logOffEvent; + } + +} +?> +--EXPECT-- + + + +object(IVREvents)#5 (6) { + ["version"]=> + string(3) "1.0" + ["activityId"]=> + int(101) + ["messageId"]=> + int(12345) + ["source"]=> + string(3) "IVR" + ["logOnEvent"]=> + NULL + ["logOffEvent"]=> + array(1) { + [0]=> + object(LogOffEvent)#6 (4) { + ["audienceMemberId"]=> + int(34567) + ["timestamp"]=> + string(25) "2005-11-08T11:22:07+03:00" + ["smokeStatus"]=> + string(6) "Smoked" + ["callInitiator"]=> + string(3) "IVR" + } + } +} diff --git a/ext/soap/tests/bugs/bug36226-2.wsdl b/ext/soap/tests/bugs/bug36226-2.wsdl new file mode 100755 index 0000000000..18c2ce3c00 --- /dev/null +++ b/ext/soap/tests/bugs/bug36226-2.wsdl @@ -0,0 +1,543 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +