Skip to content

Commit 1d56340

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Revert "Fix bug #69280: SoapClient classmap doesn't support fully qualified class name (#14398)"
2 parents e811bff + 2829065 commit 1d56340

File tree

7 files changed

+16
-144
lines changed

7 files changed

+16
-144
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ PHP NEWS
4949
- Soap:
5050
. Fixed bug #55639 (Digest autentication dont work). (nielsdos)
5151
. Fix SoapFault property destruction. (nielsdos)
52+
. Fixed bug GH-15252 (SOAP XML broken since PHP 8.3.9 when using classmap
53+
constructor option). (nielsdos)
5254

5355
- Standard:
5456
. Fix passing non-finite timeout values in stream functions. (nielsdos)

ext/soap/php_encoding.c

+6-47
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,11 @@ static xmlNodePtr master_to_xml_int(encodePtr encode, zval *data, int style, xml
449449
zend_string *type_name;
450450

451451
ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(SOAP_GLOBAL(class_map), type_name, tmp) {
452-
if (ZSTR_LEN(ce->name) == Z_STRLEN_P(tmp) &&
453-
zend_binary_strncasecmp(ZSTR_VAL(ce->name), ZSTR_LEN(ce->name), Z_STRVAL_P(tmp), ZSTR_LEN(ce->name), ZSTR_LEN(ce->name)) == 0) {
452+
ZVAL_DEREF(tmp);
453+
if (Z_TYPE_P(tmp) == IS_STRING &&
454+
ZSTR_LEN(ce->name) == Z_STRLEN_P(tmp) &&
455+
zend_binary_strncasecmp(ZSTR_VAL(ce->name), ZSTR_LEN(ce->name), Z_STRVAL_P(tmp), ZSTR_LEN(ce->name), ZSTR_LEN(ce->name)) == 0 &&
456+
type_name) {
454457

455458
/* TODO: namespace isn't stored */
456459
encodePtr enc = NULL;
@@ -1379,6 +1382,7 @@ static zval *to_zval_object_ex(zval *ret, encodeTypePtr type, xmlNodePtr data, z
13791382
zend_class_entry *tmp;
13801383

13811384
if ((classname = zend_hash_str_find_deref(SOAP_GLOBAL(class_map), type->type_str, strlen(type->type_str))) != NULL &&
1385+
Z_TYPE_P(classname) == IS_STRING &&
13821386
(tmp = zend_fetch_class(Z_STR_P(classname), ZEND_FETCH_CLASS_AUTO)) != NULL) {
13831387
ce = tmp;
13841388
}
@@ -3637,48 +3641,3 @@ void delete_encoder_persistent(zval *zv)
36373641
assert(t->details.map == NULL);
36383642
free(t);
36393643
}
3640-
3641-
/* Normalize leading backslash similarly to how the engine strips it away. */
3642-
static inline zend_string *drop_leading_backslash(zend_string *str) {
3643-
if (ZSTR_VAL(str)[0] == '\\') {
3644-
return zend_string_init(ZSTR_VAL(str) + 1, ZSTR_LEN(str) - 1, false);
3645-
} else {
3646-
return zend_string_copy(str);
3647-
}
3648-
}
3649-
3650-
static HashTable *create_normalized_classmap_copy(HashTable *class_map)
3651-
{
3652-
HashTable *normalized = zend_new_array(zend_hash_num_elements(class_map));
3653-
3654-
zend_string *key;
3655-
zval *value;
3656-
ZEND_HASH_FOREACH_STR_KEY_VAL(class_map, key, value) {
3657-
ZVAL_DEREF(value);
3658-
3659-
if (key != NULL && Z_TYPE_P(value) == IS_STRING) {
3660-
zval zv;
3661-
ZVAL_STR(&zv, drop_leading_backslash(Z_STR_P(value)));
3662-
zend_hash_add_new(normalized, key, &zv);
3663-
}
3664-
} ZEND_HASH_FOREACH_END();
3665-
3666-
return normalized;
3667-
}
3668-
3669-
void create_normalized_classmap(zval *return_value, zval *class_map)
3670-
{
3671-
/* Check if we need to make a copy. */
3672-
zend_string *key;
3673-
zval *value;
3674-
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARR_P(class_map), key, value) {
3675-
if (key == NULL || Z_TYPE_P(value) != IS_STRING || ZSTR_VAL(Z_STR_P(value))[0] == '\\') {
3676-
/* TODO: should probably throw in some of these cases to indicate programmer error,
3677-
* e.g. in the case where a non-string (after dereferencing) is provided. */
3678-
RETURN_ARR(create_normalized_classmap_copy(Z_ARR_P(class_map)));
3679-
}
3680-
} ZEND_HASH_FOREACH_END();
3681-
3682-
/* We didn't have to make an actual copy, just increment the refcount. */
3683-
RETURN_COPY(class_map);
3684-
}

ext/soap/php_encoding.h

-2
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,6 @@ encodePtr get_conversion(int encode);
214214
void delete_encoder(zval *zv);
215215
void delete_encoder_persistent(zval *zv);
216216

217-
void create_normalized_classmap(zval *return_value, zval *class_map);
218-
219217
extern const encode defaultEncoding[];
220218
extern int numDefaultEncodings;
221219

ext/soap/php_soap.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ struct _soapService {
9898
char *actor;
9999
char *uri;
100100
xmlCharEncodingHandlerPtr encoding;
101-
zval class_map;
101+
HashTable *class_map;
102102
int features;
103103
struct _soapHeader **soap_headers_ptr;
104104
int send_errors;

ext/soap/soap.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ PHP_METHOD(SoapServer, __construct)
837837

838838
if ((tmp = zend_hash_str_find(ht, "classmap", sizeof("classmap")-1)) != NULL &&
839839
Z_TYPE_P(tmp) == IS_ARRAY) {
840-
create_normalized_classmap(&service->class_map, tmp);
840+
service->class_map = zend_array_dup(Z_ARRVAL_P(tmp));
841841
}
842842

843843
if ((tmp = zend_hash_str_find(ht, "typemap", sizeof("typemap")-1)) != NULL &&
@@ -1303,7 +1303,7 @@ PHP_METHOD(SoapServer, handle)
13031303
old_encoding = SOAP_GLOBAL(encoding);
13041304
SOAP_GLOBAL(encoding) = service->encoding;
13051305
old_class_map = SOAP_GLOBAL(class_map);
1306-
SOAP_GLOBAL(class_map) = Z_ARR(service->class_map);
1306+
SOAP_GLOBAL(class_map) = service->class_map;
13071307
old_typemap = SOAP_GLOBAL(typemap);
13081308
SOAP_GLOBAL(typemap) = service->typemap;
13091309
old_features = SOAP_GLOBAL(features);
@@ -2003,7 +2003,7 @@ PHP_METHOD(SoapClient, __construct)
20032003
}
20042004
if ((tmp = zend_hash_str_find(ht, "classmap", sizeof("classmap")-1)) != NULL &&
20052005
Z_TYPE_P(tmp) == IS_ARRAY) {
2006-
create_normalized_classmap(Z_CLIENT_CLASSMAP_P(this_ptr), tmp);
2006+
ZVAL_COPY(Z_CLIENT_CLASSMAP_P(this_ptr), tmp);
20072007
}
20082008

20092009
if ((tmp = zend_hash_str_find(ht, "typemap", sizeof("typemap")-1)) != NULL &&
@@ -4405,7 +4405,10 @@ static void delete_service(void *data) /* {{{ */
44054405
if (service->encoding) {
44064406
xmlCharEncCloseFunc(service->encoding);
44074407
}
4408-
zval_ptr_dtor(&service->class_map);
4408+
if (service->class_map) {
4409+
zend_hash_destroy(service->class_map);
4410+
FREE_HASHTABLE(service->class_map);
4411+
}
44094412
zval_ptr_dtor(&service->soap_object);
44104413
efree(service);
44114414
}

ext/soap/tests/bug69280.phpt

-44
This file was deleted.

ext/soap/tests/bug69280.wsdl

-46
This file was deleted.

0 commit comments

Comments
 (0)