Skip to content

Commit 60336de

Browse files
committed
1 parent 44b3cb2 commit 60336de

File tree

7 files changed

+113
-34
lines changed

7 files changed

+113
-34
lines changed

UPGRADING

+4
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ PHP 8.4 UPGRADE NOTES
139139
. SoapClient::$httpurl is now a Soap\Url object rather than a resource.
140140
Checks using is_resource() (i.e. is_resource($client->httpurl)) should be
141141
replaced with checks for null (i.e. $client->httpurl !== null).
142+
. SoapClient::$sdl is now a Soap\Sdl object rather than a resource.
143+
Checks using is_resource() (i.e. is_resource($client->sdl)) should be
144+
replaced with checks for null (i.e. $client->sdl !== null).
145+
142146
- SPL:
143147
. Out of bounds accesses in SplFixedArray now throw an exception of type
144148
OutOfBoundsException instead of RuntimeException. As OutOfBoundsException

ext/soap/php_sdl.c

+3-5
Original file line numberDiff line numberDiff line change
@@ -3449,12 +3449,10 @@ void delete_sdl_impl(void *handle)
34493449
efree(tmp);
34503450
}
34513451

3452-
void delete_sdl(void *handle)
3452+
void delete_sdl(sdl *handle)
34533453
{
3454-
sdlPtr tmp = (sdlPtr)handle;
3455-
3456-
if (!tmp->is_persistent) {
3457-
delete_sdl_impl(tmp);
3454+
if (!handle->is_persistent) {
3455+
delete_sdl_impl(handle);
34583456
}
34593457
}
34603458

ext/soap/php_sdl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ encodePtr get_encoder_ex(sdlPtr sdl, const char *nscat, int len);
260260
sdlBindingPtr get_binding_from_type(sdlPtr sdl, sdlBindingType type);
261261
sdlBindingPtr get_binding_from_name(sdlPtr sdl, char *name, char *ns);
262262

263-
void delete_sdl(void *handle);
263+
void delete_sdl(sdl *handle);
264264
void delete_sdl_impl(void *handle);
265265

266266
void sdl_set_uri_credentials(sdlCtx *ctx, char *uri);

ext/soap/php_soap.h

+7
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ ZEND_TSRMLS_CACHE_EXTERN()
193193
extern zend_class_entry* soap_class_entry;
194194
extern zend_class_entry* soap_var_class_entry;
195195
extern zend_class_entry* soap_url_class_entry;
196+
extern zend_class_entry* soap_sdl_class_entry;
196197

197198
void add_soap_fault(zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail);
198199

@@ -263,4 +264,10 @@ static inline soap_url_object *soap_url_object_fetch(zend_object *obj)
263264
}
264265

265266
#define Z_SOAP_URL_P(zv) soap_url_object_fetch(Z_OBJ_P(zv))
267+
268+
typedef struct soap_sdl_object {
269+
sdl *sdl;
270+
zend_object std;
271+
} soap_sdl_object;
272+
266273
#endif

ext/soap/soap.c

+71-24
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include "ext/standard/php_incomplete_class.h"
3030

3131

32-
static int le_sdl = 0;
3332
static int le_typemap = 0;
3433

3534
typedef struct _soapHeader {
@@ -128,15 +127,13 @@ static void soap_error_handler(int error_num, zend_string *error_filename, const
128127
#define FETCH_THIS_SDL(ss) \
129128
{ \
130129
zval *__tmp = Z_CLIENT_SDL_P(ZEND_THIS); \
131-
if (Z_TYPE_P(__tmp) == IS_RESOURCE) { \
132-
FETCH_SDL_RES(ss,__tmp); \
130+
if (Z_TYPE_P(__tmp) == IS_OBJECT && instanceof_function(Z_OBJCE_P(__tmp), soap_sdl_class_entry)) { \
131+
ss = Z_SOAP_SDL_P(__tmp)->sdl; \
133132
} else { \
134133
ss = NULL; \
135134
} \
136135
}
137136

138-
#define FETCH_SDL_RES(ss,tmp) ss = (sdlPtr) zend_fetch_resource_ex(tmp, "sdl", le_sdl)
139-
140137
#define FETCH_TYPEMAP_RES(ss,tmp) ss = (HashTable*) zend_fetch_resource_ex(tmp, "typemap", le_typemap)
141138

142139
#define Z_PARAM_NAME_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 0))
@@ -177,9 +174,11 @@ static zend_class_entry* soap_header_class_entry;
177174
static zend_class_entry* soap_param_class_entry;
178175
zend_class_entry* soap_var_class_entry;
179176
zend_class_entry *soap_url_class_entry;
177+
zend_class_entry *soap_sdl_class_entry;
180178

181179
static zend_object_handlers soap_server_object_handlers;
182180
static zend_object_handlers soap_url_object_handlers;
181+
static zend_object_handlers soap_sdl_object_handlers;
183182

184183
typedef struct {
185184
soapServicePtr service;
@@ -234,6 +233,43 @@ static zend_function *soap_url_object_get_constructor(zend_object *object)
234233

235234
return NULL;
236235
}
236+
237+
static inline soap_sdl_object *soap_sdl_object_fetch(zend_object *obj)
238+
{
239+
return (soap_sdl_object *) ((char *) obj - XtOffsetOf(soap_sdl_object, std));
240+
}
241+
242+
#define Z_SOAP_SDL_P(zv) soap_sdl_object_fetch(Z_OBJ_P(zv))
243+
244+
static zend_object *soap_sdl_object_create(zend_class_entry *ce)
245+
{
246+
soap_sdl_object *sdl_obj = zend_object_alloc(sizeof(soap_sdl_object), ce);
247+
248+
zend_object_std_init(&sdl_obj->std, ce);
249+
object_properties_init(&sdl_obj->std, ce);
250+
251+
return &sdl_obj->std;
252+
}
253+
254+
static void soap_sdl_object_free(zend_object *obj)
255+
{
256+
soap_sdl_object *sdl_obj = soap_sdl_object_fetch(obj);
257+
258+
if (sdl_obj->sdl) {
259+
delete_sdl(sdl_obj->sdl);
260+
sdl_obj->sdl = NULL;
261+
}
262+
263+
zend_object_std_dtor(&sdl_obj->std);
264+
}
265+
266+
static zend_function *soap_sdl_object_get_constructor(zend_object *object)
267+
{
268+
zend_throw_error(NULL, "Cannot directly construct Soap\\Sdl");
269+
270+
return NULL;
271+
}
272+
237273
ZEND_DECLARE_MODULE_GLOBALS(soap)
238274

239275
static void (*old_error_handler)(int, zend_string *, const uint32_t, zend_string *);
@@ -418,11 +454,6 @@ PHP_RINIT_FUNCTION(soap)
418454
return SUCCESS;
419455
}
420456

421-
static void delete_sdl_res(zend_resource *res)
422-
{
423-
delete_sdl(res->ptr);
424-
}
425-
426457
static void delete_hashtable_res(zend_resource *res)
427458
{
428459
delete_hashtable(res->ptr);
@@ -458,7 +489,6 @@ PHP_MINIT_FUNCTION(soap)
458489

459490
soap_header_class_entry = register_class_SoapHeader();
460491

461-
le_sdl = zend_register_list_destructors_ex(delete_sdl_res, NULL, "SOAP SDL", module_number);
462492
le_typemap = zend_register_list_destructors_ex(delete_hashtable_res, NULL, "SOAP table", module_number);
463493

464494
soap_url_class_entry = register_class_Soap_Url();
@@ -472,6 +502,17 @@ PHP_MINIT_FUNCTION(soap)
472502
soap_url_object_handlers.clone_obj = NULL;
473503
soap_url_object_handlers.compare = zend_objects_not_comparable;
474504

505+
soap_sdl_class_entry = register_class_Soap_Sdl();
506+
soap_sdl_class_entry->create_object = soap_sdl_object_create;
507+
soap_sdl_class_entry->default_object_handlers = &soap_sdl_object_handlers;
508+
509+
memcpy(&soap_sdl_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
510+
soap_sdl_object_handlers.offset = XtOffsetOf(soap_sdl_object, std);
511+
soap_sdl_object_handlers.free_obj = soap_sdl_object_free;
512+
soap_sdl_object_handlers.get_constructor = soap_sdl_object_get_constructor;
513+
soap_sdl_object_handlers.clone_obj = NULL;
514+
soap_sdl_object_handlers.compare = zend_objects_not_comparable;
515+
475516
register_soap_symbols(module_number);
476517

477518
old_error_handler = zend_error_cb;
@@ -2086,15 +2127,20 @@ PHP_METHOD(SoapClient, __construct)
20862127

20872128
if (wsdl) {
20882129
int old_soap_version;
2089-
zend_resource *res;
20902130

20912131
old_soap_version = SOAP_GLOBAL(soap_version);
20922132
SOAP_GLOBAL(soap_version) = soap_version;
20932133

20942134
sdl = get_sdl(this_ptr, ZSTR_VAL(wsdl), cache_wsdl);
2095-
res = zend_register_resource(sdl, le_sdl);
20962135

2097-
ZVAL_RES(Z_CLIENT_SDL_P(this_ptr), res);
2136+
zval *sdl_zval = Z_CLIENT_SDL_P(this_ptr);
2137+
if (Z_TYPE_P(sdl_zval) == IS_OBJECT) {
2138+
zval_ptr_dtor(sdl_zval);
2139+
}
2140+
2141+
object_init_ex(sdl_zval, soap_sdl_class_entry);
2142+
soap_sdl_object *sdl_object = Z_SOAP_SDL_P(sdl_zval);
2143+
sdl_object->sdl = sdl;
20982144

20992145
SOAP_GLOBAL(soap_version) = old_soap_version;
21002146
}
@@ -2227,8 +2273,11 @@ static void do_soap_call(zend_execute_data *execute_data,
22272273
}
22282274

22292275
tmp = Z_CLIENT_SDL_P(this_ptr);
2230-
if (Z_TYPE_P(tmp) == IS_RESOURCE) {
2231-
FETCH_SDL_RES(sdl,tmp);
2276+
if (Z_TYPE_P(tmp) == IS_OBJECT) {
2277+
#ifdef ZEND_DEBUG
2278+
ZEND_ASSERT(instanceof_function(Z_OBJCE_P(tmp), soap_sdl_class_entry));
2279+
#endif
2280+
sdl = Z_SOAP_SDL_P(tmp)->sdl;
22322281
}
22332282

22342283
tmp = Z_CLIENT_TYPEMAP_P(this_ptr);
@@ -2536,14 +2585,13 @@ PHP_METHOD(SoapClient, __soapCall)
25362585
/* {{{ Returns list of SOAP functions */
25372586
PHP_METHOD(SoapClient, __getFunctions)
25382587
{
2539-
sdlPtr sdl;
2540-
2541-
FETCH_THIS_SDL(sdl);
2542-
25432588
if (zend_parse_parameters_none() == FAILURE) {
25442589
RETURN_THROWS();
25452590
}
25462591

2592+
sdl *sdl;
2593+
FETCH_THIS_SDL(sdl);
2594+
25472595
if (sdl) {
25482596
smart_str buf = {0};
25492597
sdlFunctionPtr function;
@@ -2562,14 +2610,13 @@ PHP_METHOD(SoapClient, __getFunctions)
25622610
/* {{{ Returns list of SOAP types */
25632611
PHP_METHOD(SoapClient, __getTypes)
25642612
{
2565-
sdlPtr sdl;
2566-
2567-
FETCH_THIS_SDL(sdl);
2568-
25692613
if (zend_parse_parameters_none() == FAILURE) {
25702614
RETURN_THROWS();
25712615
}
25722616

2617+
sdl *sdl;
2618+
FETCH_THIS_SDL(sdl);
2619+
25732620
if (sdl) {
25742621
sdlTypePtr type;
25752622
smart_str buf = {0};

ext/soap/soap.stub.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
final class Url
1111
{
1212
}
13+
14+
/**
15+
* @strict-properties
16+
* @not-serializable
17+
*/
18+
final class Sdl
19+
{
20+
}
1321
}
1422

1523
namespace {
@@ -528,8 +536,7 @@ class SoapClient
528536
private ?string $location = null;
529537
private bool $trace = false;
530538
private ?int $compression = null;
531-
/** @var resource|null */
532-
private $sdl = null;
539+
private ?Soap\Sdl $sdl = null;
533540
/** @var resource|null */
534541
private $typemap = null;
535542
/** @var resource|null */

ext/soap/soap_arginfo.h

+18-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)