From 24cb5bd18485b16d64a00ec9c4a91416dbd38fd6 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Thu, 29 May 2025 21:20:59 +0200 Subject: [PATCH 1/2] Implement request #55503: Extend __getTypes to support enumerations I ported the patch to 8.5. Co-authored-by: datibbaw --- NEWS | 2 ++ UPGRADING | 3 +++ ext/soap/soap.c | 16 ++++++++++++++++ ext/soap/tests/bugs/bug42359.phpt | 4 ++-- ext/soap/tests/req55503.phpt | 14 ++++++++++++++ ext/soap/tests/req55503.wsdl | 24 ++++++++++++++++++++++++ 6 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 ext/soap/tests/req55503.phpt create mode 100644 ext/soap/tests/req55503.wsdl diff --git a/NEWS b/NEWS index baf838481682c..19da88d0dd3cb 100644 --- a/NEWS +++ b/NEWS @@ -187,6 +187,8 @@ PHP NEWS . Fix namespace handling of WSDL and XML schema in SOAP, fixing at least GH-16320 and bug #68576. (nielsdos) . Fixed bug #70951 (Segmentation fault on invalid WSDL cache). (nielsdos) + . Implement request #55503 (Extend __getTypes to support enumerations). + (nielsdos, datibbaw) - Sockets: . Added IPPROTO_ICMP/IPPROTO_ICMPV6 to create raw socket for ICMP usage. diff --git a/UPGRADING b/UPGRADING index 46284f16ce3f4..254c07e09c880 100644 --- a/UPGRADING +++ b/UPGRADING @@ -194,6 +194,9 @@ PHP 8.5 UPGRADE NOTES IntlListFormatter::WIDTH_NARROW widths. It is supported from icu 67. +- SOAP: + . Enumeration cases are now dumped in __getTypes(). + - XSL: . The $namespace argument of XSLTProcessor::getParameter(), XSLTProcessor::setParameter() and XSLTProcessor::removeParameter() diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 094730b88f412..e0577ac648cae 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -4404,6 +4404,22 @@ static void type_to_string(sdlTypePtr type, smart_str *buf, int level) /* {{{ */ smart_str_appendl(buf, "anyType ", sizeof("anyType ")-1); } smart_str_appendl(buf, type->name, strlen(type->name)); + + if (type->restrictions && type->restrictions->enumeration) { + zend_string *key; + bool first = true; + + smart_str_appends(buf, " {"); + ZEND_HASH_MAP_FOREACH_STR_KEY(type->restrictions->enumeration, key) { + if (first) { + first = false; + } else { + smart_str_appends(buf, ", "); + } + smart_str_append(buf, key); + } ZEND_HASH_FOREACH_END(); + smart_str_appendc(buf, '}'); + } break; case XSD_TYPEKIND_LIST: smart_str_appendl(buf, "list ", 5); diff --git a/ext/soap/tests/bugs/bug42359.phpt b/ext/soap/tests/bugs/bug42359.phpt index 0cb4f75c69be4..f717561e7caeb 100644 --- a/ext/soap/tests/bugs/bug42359.phpt +++ b/ext/soap/tests/bugs/bug42359.phpt @@ -13,7 +13,7 @@ print_r($soap->__getTypes()); Array ( [0] => list listItem {anonymous1} - [1] => string anonymous1 - [2] => string enumItem + [1] => string anonymous1 {test1, test2} + [2] => string enumItem {test1, test2} [3] => list listItem2 {enumItem} ) diff --git a/ext/soap/tests/req55503.phpt b/ext/soap/tests/req55503.phpt new file mode 100644 index 0000000000000..c58d5963facc6 --- /dev/null +++ b/ext/soap/tests/req55503.phpt @@ -0,0 +1,14 @@ +--TEST-- +Request #55503 (Extend __getTypes to support enumerations) +--EXTENSIONS-- +soap +--FILE-- +__getTypes()); +?> +--EXPECT-- +array(1) { + [0]=> + string(102) "anyType PersonaMemberType {NEW, LIMITED, FREE, PAID_ACTIVE, TRIAL_ACTIVE, PAID_EXPIRED, TRIAL_EXPIRED}" +} diff --git a/ext/soap/tests/req55503.wsdl b/ext/soap/tests/req55503.wsdl new file mode 100644 index 0000000000000..26c9232386fbd --- /dev/null +++ b/ext/soap/tests/req55503.wsdl @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + From 6f7488ab5d1562861fd469ec0b5b026bc4f77d29 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Fri, 30 May 2025 23:53:15 +0200 Subject: [PATCH 2/2] fix wsdl --- ext/soap/tests/req55503.phpt | 2 ++ ext/soap/tests/req55503.wsdl | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/ext/soap/tests/req55503.phpt b/ext/soap/tests/req55503.phpt index c58d5963facc6..ac3c8627048c1 100644 --- a/ext/soap/tests/req55503.phpt +++ b/ext/soap/tests/req55503.phpt @@ -2,6 +2,8 @@ Request #55503 (Extend __getTypes to support enumerations) --EXTENSIONS-- soap +--INI-- +soap.wsdl_cache_enabled=0 --FILE-- + + + + + +