From bdf8b9ed2d650f011bb72d4ad9f1bd71bc85478e Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 19 Aug 2021 14:10:21 +0200 Subject: [PATCH] Declare SoapServer::$service property --- ext/soap/soap.c | 27 +++++++++++++-------------- ext/soap/soap.stub.php | 3 +++ ext/soap/soap_arginfo.h | 8 +++++++- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 69ec7337b6b..ea8b1685e68 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -143,12 +143,15 @@ static void soap_error_handler(int error_num, zend_string *error_filename, const #define FIND_TYPEMAP_PROPERTY(ss,tmp) (tmp = zend_hash_str_find(Z_OBJPROP_P(ss), "typemap", sizeof("typemap")-1)) #define FETCH_TYPEMAP_RES(ss,tmp) ss = (HashTable*) zend_fetch_resource_ex(tmp, "typemap", le_typemap) +#define Z_PARAM_NAME_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 0) +#define Z_PARAM_DATA_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 1) +#define Z_SERVER_SERVICE_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 0) + #define FETCH_THIS_SERVICE(ss) \ { \ - zval *tmp; \ - if ((tmp = zend_hash_str_find(Z_OBJPROP_P(ZEND_THIS),"service", sizeof("service")-1)) != NULL) { \ - ss = (soapServicePtr)zend_fetch_resource_ex(tmp, "service", le_service); \ - } else { \ + zval *tmp = Z_SERVER_SERVICE_P(ZEND_THIS); \ + ss = (soapServicePtr)zend_fetch_resource_ex(tmp, "service", le_service); \ + if (!ss) { \ zend_throw_error(NULL, "Cannot fetch SoapServer object"); \ SOAP_SERVER_END_CODE(); \ RETURN_THROWS(); \ @@ -162,9 +165,6 @@ static zend_class_entry* soap_header_class_entry; static zend_class_entry* soap_param_class_entry; zend_class_entry* soap_var_class_entry; -#define Z_PARAM_NAME_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 0) -#define Z_PARAM_DATA_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 1) - ZEND_DECLARE_MODULE_GLOBALS(soap) static void (*old_error_handler)(int, zend_string *, const uint32_t, zend_string *); @@ -927,7 +927,7 @@ PHP_METHOD(SoapServer, __construct) } res = zend_register_resource(service, le_service); - add_property_resource(ZEND_THIS, "service", res); + ZVAL_RES(Z_SERVER_SERVICE_P(ZEND_THIS), res); SOAP_SERVER_END_CODE(); } @@ -1841,20 +1841,19 @@ static zend_never_inline ZEND_COLD void soap_real_error_handler(int error_num, z zval fault_obj; if (error_num & E_FATAL_ERRORS) { - char* code = SOAP_GLOBAL(error_code); + char *code = SOAP_GLOBAL(error_code); + zval *error_object = &SOAP_GLOBAL(error_object); zend_string *buffer; zval outbuf; - zval *tmp; soapServicePtr service; ZVAL_UNDEF(&outbuf); if (code == NULL) { code = "Server"; } - if (Z_OBJ(SOAP_GLOBAL(error_object)) && - instanceof_function(Z_OBJCE(SOAP_GLOBAL(error_object)), soap_server_class_entry) && - (tmp = zend_hash_str_find(Z_OBJPROP(SOAP_GLOBAL(error_object)), "service", sizeof("service")-1)) != NULL && - (service = (soapServicePtr)zend_fetch_resource_ex(tmp, "service", le_service)) && + if (Z_OBJ_P(error_object) && + instanceof_function(Z_OBJCE_P(error_object), soap_server_class_entry) && + (service = (soapServicePtr)zend_fetch_resource_ex(Z_SERVER_SERVICE_P(error_object), "service", le_service)) && !service->send_errors) { buffer = zend_string_init("Internal Error", sizeof("Internal Error")-1, 0); } else { diff --git a/ext/soap/soap.stub.php b/ext/soap/soap.stub.php index c71dcbfa496..6e743ec37c8 100644 --- a/ext/soap/soap.stub.php +++ b/ext/soap/soap.stub.php @@ -40,6 +40,9 @@ class SoapVar class SoapServer { + /** @var resource */ + public $service; + public function __construct(?string $wsdl, array $options = []) {} /** @tentative-return-type */ diff --git a/ext/soap/soap_arginfo.h b/ext/soap/soap_arginfo.h index 6f0ef10ffb8..c4c695a7d72 100644 --- a/ext/soap/soap_arginfo.h +++ b/ext/soap/soap_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 6e48f3873213091cf629f9dc7f2c7285ffcf23eb */ + * Stub hash: f1f7c9c948e33f0b48ff66ea3515dc995ee8f870 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_use_soap_error_handler, 0, 0, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, enable, _IS_BOOL, 0, "true") @@ -328,6 +328,12 @@ static zend_class_entry *register_class_SoapServer(void) INIT_CLASS_ENTRY(ce, "SoapServer", class_SoapServer_methods); class_entry = zend_register_internal_class_ex(&ce, NULL); + zval property_service_default_value; + ZVAL_NULL(&property_service_default_value); + zend_string *property_service_name = zend_string_init("service", sizeof("service") - 1, 1); + zend_declare_property_ex(class_entry, property_service_name, &property_service_default_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(property_service_name); + return class_entry; }