Commit 57001e6fd88 for php
commit 57001e6fd8850479ce3b228a502847980b8a37ff
Author: Gina Peter Banyard <girgias@php.net>
Date: Sun Jul 6 17:51:16 2025 +0100
soap: store zend_function pointers in soap_functions.ft field
diff --git a/ext/soap/soap.c b/ext/soap/soap.c
index a9a7ce8d205..8c0cff80d90 100644
--- a/ext/soap/soap.c
+++ b/ext/soap/soap.c
@@ -1100,7 +1100,9 @@ PHP_METHOD(SoapServer, __construct)
service->version = version;
service->type = SOAP_FUNCTIONS;
service->soap_functions.functions_all = false;
- service->soap_functions.ft = zend_new_array(0);
+ ALLOC_HASHTABLE(service->soap_functions.ft);
+ /* This hashtable contains zend_function pointers so doesn't need a destructor */
+ zend_hash_init(service->soap_functions.ft, 0, NULL, NULL, false);
SOAP_SERVER_BEGIN_CODE();
if (wsdl) {
@@ -1226,7 +1228,7 @@ PHP_METHOD(SoapServer, setObject)
PHP_METHOD(SoapServer, getFunctions)
{
soapServicePtr service;
- HashTable *ft = NULL;
+ const HashTable *ft = NULL;
ZEND_PARSE_PARAMETERS_NONE();
@@ -1240,11 +1242,7 @@ PHP_METHOD(SoapServer, getFunctions)
} else if (service->soap_functions.functions_all) {
ft = EG(function_table);
} else if (service->soap_functions.ft != NULL) {
- zval *name;
-
- ZEND_HASH_MAP_FOREACH_VAL(service->soap_functions.ft, name) {
- add_next_index_str(return_value, zend_string_copy(Z_STR_P(name)));
- } ZEND_HASH_FOREACH_END();
+ ft = service->soap_functions.ft;
}
if (ft != NULL) {
zend_function *f;
@@ -1263,7 +1261,7 @@ PHP_METHOD(SoapServer, getFunctions)
PHP_METHOD(SoapServer, addFunction)
{
soapServicePtr service;
- zval *function_name, function_copy;
+ zval *function_name;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &function_name) == FAILURE) {
RETURN_THROWS();
@@ -1279,7 +1277,9 @@ PHP_METHOD(SoapServer, addFunction)
if (service->soap_functions.ft == NULL) {
service->soap_functions.functions_all = false;
- service->soap_functions.ft = zend_new_array(zend_hash_num_elements(Z_ARRVAL_P(function_name)));
+ ALLOC_HASHTABLE(service->soap_functions.ft);
+ /* This hashtable contains zend_function pointers so doesn't need a destructor */
+ zend_hash_init(service->soap_functions.ft, zend_hash_num_elements(Z_ARRVAL_P(function_name)), NULL, NULL, false);
}
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(function_name), tmp_function) {
@@ -1292,15 +1292,15 @@ PHP_METHOD(SoapServer, addFunction)
}
key = zend_string_tolower(Z_STR_P(tmp_function));
+ f = zend_hash_find_ptr(EG(function_table), key);
- if ((f = zend_hash_find_ptr(EG(function_table), key)) == NULL) {
+ if (f == NULL) {
zend_string_release_ex(key, false);
zend_type_error("SoapServer::addFunction(): Function \"%s\" not found", Z_STRVAL_P(tmp_function));
RETURN_THROWS();
}
- ZVAL_STR_COPY(&function_copy, f->common.function_name);
- zend_hash_update(service->soap_functions.ft, key, &function_copy);
+ zend_hash_update_ptr(service->soap_functions.ft, key, f);
zend_string_release_ex(key, 0);
} ZEND_HASH_FOREACH_END();
@@ -1310,19 +1310,20 @@ PHP_METHOD(SoapServer, addFunction)
zend_function *f;
key = zend_string_tolower(Z_STR_P(function_name));
-
- if ((f = zend_hash_find_ptr(EG(function_table), key)) == NULL) {
+ f = zend_hash_find_ptr(EG(function_table), key);
+ if (f == NULL) {
zend_string_release_ex(key, false);
zend_argument_type_error(1, "must be a valid function name, function \"%s\" not found", Z_STRVAL_P(function_name));
RETURN_THROWS();
}
if (service->soap_functions.ft == NULL) {
service->soap_functions.functions_all = false;
- service->soap_functions.ft = zend_new_array(0);
+ ALLOC_HASHTABLE(service->soap_functions.ft);
+ /* This hashtable contains zend_function pointers so doesn't need a destructor */
+ zend_hash_init(service->soap_functions.ft, 0, NULL, NULL, false);
}
- ZVAL_STR_COPY(&function_copy, f->common.function_name);
- zend_hash_update(service->soap_functions.ft, key, &function_copy);
+ zend_hash_update_ptr(service->soap_functions.ft, key, f);
zend_string_release_ex(key, 0);
} else if (Z_TYPE_P(function_name) == IS_LONG) {
if (Z_LVAL_P(function_name) == SOAP_FUNCTIONS_ALL) {