From b94dc286e783dfd3eae210d0d088a7c2d500399b Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 27 Sep 2005 15:24:47 +0000 Subject: [PATCH] Fixed bug #34643 (wsdl default value has no effect) --- ext/soap/soap.c | 12 ++++++++ ext/soap/tests/bugs/bug34643.phpt | 46 +++++++++++++++++++++++++++++++ ext/soap/tests/bugs/bug34643.wsdl | 42 ++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100755 ext/soap/tests/bugs/bug34643.phpt create mode 100755 ext/soap/tests/bugs/bug34643.wsdl diff --git a/ext/soap/soap.c b/ext/soap/soap.c index bb50bfd54a..cc20eff4c7 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -4018,9 +4018,21 @@ static xmlNodePtr serialize_zval(zval *val, sdlParamPtr param, char *paramName, { xmlNodePtr xmlParam; encodePtr enc; + zval defval; if (param != NULL) { enc = param->encode; + if (val == NULL || Z_TYPE_P(val) == IS_NULL) { + if (param->element) { + if (param->element->fixed) { + ZVAL_STRING(&defval, param->element->fixed, 0); + val = &defval; + } else if (param->element->def && !param->element->nillable) { + ZVAL_STRING(&defval, param->element->def, 0); + val = &defval; + } + } + } } else { enc = NULL; } diff --git a/ext/soap/tests/bugs/bug34643.phpt b/ext/soap/tests/bugs/bug34643.phpt new file mode 100755 index 0000000000..b8c92e281b --- /dev/null +++ b/ext/soap/tests/bugs/bug34643.phpt @@ -0,0 +1,46 @@ +--TEST-- +Bug #34643 (wsdl default value) +--SKIPIF-- + +--INI-- +soap.wsdl_cache_enabled=0 +--FILE-- +server = new SoapServer($wsdl, $options); + $this->server->setClass('fp'); + } + + function __doRequest($request, $location, $action, $version) { + ob_start(); + $this->server->handle($request); + $response = ob_get_contents(); + ob_end_clean(); + return $response; + } + +} + +$cl = new LocalSoapClient(dirname(__FILE__).'/bug34643.wsdl', array("trace"=>1)); +print_r($cl->__getFunctions()); +echo $cl->get_it("aaa")."\n"; +echo $cl->get_it()."\n"; +?> +--EXPECT-- +Array +( + [0] => string get_it(string $opt) +) +aaa +zzz diff --git a/ext/soap/tests/bugs/bug34643.wsdl b/ext/soap/tests/bugs/bug34643.wsdl new file mode 100755 index 0000000000..24c3a50828 --- /dev/null +++ b/ext/soap/tests/bugs/bug34643.wsdl @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.50.1