Skip to content

Commit 9205910

Browse files
committed
Migrate SOAP table resource to array
Related to https://wiki.php.net/rfc/resource_to_object_conversion and php/php-tasks#6
1 parent 48971af commit 9205910

File tree

4 files changed

+9
-27
lines changed

4 files changed

+9
-27
lines changed

UPGRADING

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ PHP 8.4 UPGRADE NOTES
142142
. SoapClient::$sdl is now a Soap\Sdl object rather than a resource.
143143
Checks using is_resource() (i.e. is_resource($client->sdl)) should be
144144
replaced with checks for null (i.e. $client->sdl !== null).
145+
. SoapClient::$typemap is now an array rather than a resource.
146+
Checks using is_resource() (i.e. is_resource($client->typemap)) should be
147+
replaced with checks for null (i.e. $client->typemap !== null).
145148

146149
- SPL:
147150
. Out of bounds accesses in SplFixedArray now throw an exception of type

ext/soap/soap.c

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
#include "zend_interfaces.h"
2929
#include "ext/standard/php_incomplete_class.h"
3030

31-
32-
static int le_typemap = 0;
33-
3431
typedef struct _soapHeader {
3532
sdlFunctionPtr function;
3633
zval function_name;
@@ -63,7 +60,6 @@ static xmlNodePtr serialize_parameter(sdlParamPtr param,zval *param_val,int inde
6360
static xmlNodePtr serialize_zval(zval *val, sdlParamPtr param, char *paramName, int style, xmlNodePtr parent);
6461

6562
static void delete_service(void *service);
66-
static void delete_hashtable(void *hashtable);
6763

6864
static void soap_error_handler(int error_num, zend_string *error_filename, const uint32_t error_lineno, zend_string *message);
6965

@@ -134,8 +130,6 @@ static void soap_error_handler(int error_num, zend_string *error_filename, const
134130
} \
135131
}
136132

137-
#define FETCH_TYPEMAP_RES(ss,tmp) ss = (HashTable*) zend_fetch_resource_ex(tmp, "typemap", le_typemap)
138-
139133
#define Z_PARAM_NAME_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 0))
140134
#define Z_PARAM_DATA_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 1))
141135

@@ -454,11 +448,6 @@ PHP_RINIT_FUNCTION(soap)
454448
return SUCCESS;
455449
}
456450

457-
static void delete_hashtable_res(zend_resource *res)
458-
{
459-
delete_hashtable(res->ptr);
460-
}
461-
462451
PHP_MINIT_FUNCTION(soap)
463452
{
464453
/* TODO: add ini entry for always use soap errors */
@@ -489,8 +478,6 @@ PHP_MINIT_FUNCTION(soap)
489478

490479
soap_header_class_entry = register_class_SoapHeader();
491480

492-
le_typemap = zend_register_list_destructors_ex(delete_hashtable_res, NULL, "SOAP table", module_number);
493-
494481
soap_url_class_entry = register_class_Soap_Url();
495482
soap_url_class_entry->create_object = soap_url_object_create;
496483
soap_url_class_entry->default_object_handlers = &soap_url_object_handlers;
@@ -2148,8 +2135,7 @@ PHP_METHOD(SoapClient, __construct)
21482135
if (typemap_ht) {
21492136
HashTable *typemap = soap_create_typemap(sdl, typemap_ht);
21502137
if (typemap) {
2151-
zend_resource *res = zend_register_resource(typemap, le_typemap);
2152-
ZVAL_RES(Z_CLIENT_TYPEMAP_P(this_ptr), res);
2138+
ZVAL_ARR(Z_CLIENT_TYPEMAP_P(this_ptr), typemap);
21532139
}
21542140
}
21552141
SOAP_CLIENT_END_CODE();
@@ -2281,8 +2267,8 @@ static void do_soap_call(zend_execute_data *execute_data,
22812267
}
22822268

22832269
tmp = Z_CLIENT_TYPEMAP_P(this_ptr);
2284-
if (Z_TYPE_P(tmp) == IS_RESOURCE) {
2285-
FETCH_TYPEMAP_RES(typemap, tmp);
2270+
if (Z_TYPE_P(tmp) == IS_ARRAY) {
2271+
typemap = Z_ARR_P(tmp);
22862272
}
22872273

22882274
clear_soap_fault(this_ptr);
@@ -4478,10 +4464,4 @@ static void delete_service(void *data) /* {{{ */
44784464
}
44794465
/* }}} */
44804466

4481-
static void delete_hashtable(void *data) /* {{{ */
4482-
{
4483-
HashTable *ht = (HashTable*)data;
4484-
zend_hash_destroy(ht);
4485-
efree(ht);
4486-
}
44874467
/* }}} */

ext/soap/soap.stub.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,7 @@ class SoapClient
537537
private bool $trace = false;
538538
private ?int $compression = null;
539539
private ?Soap\Sdl $sdl = null;
540-
/** @var resource|null */
541-
private $typemap = null;
540+
private ?array $typemap = null;
542541
/** @var resource|null */
543542
private $httpsocket = null;
544543
private ?Soap\Url $httpurl = null;

ext/soap/soap_arginfo.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)