Skip to content

Commit

Permalink
Migrate SOAP table resource to array
Browse files Browse the repository at this point in the history
  • Loading branch information
kocsismate authored and nielsdos committed May 8, 2024
1 parent 48971af commit aea77f2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 27 deletions.
3 changes: 3 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ PHP 8.4 UPGRADE NOTES
. SoapClient::$sdl is now a Soap\Sdl object rather than a resource.
Checks using is_resource() (i.e. is_resource($client->sdl)) should be
replaced with checks for null (i.e. $client->sdl !== null).
. SoapClient::$typemap is now an array rather than a resource.
Checks using is_resource() (i.e. is_resource($client->typemap)) should be
replaced with checks for null (i.e. $client->typemap !== null).

- SPL:
. Out of bounds accesses in SplFixedArray now throw an exception of type
Expand Down
26 changes: 3 additions & 23 deletions ext/soap/soap.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
#include "zend_interfaces.h"
#include "ext/standard/php_incomplete_class.h"


static int le_typemap = 0;

typedef struct _soapHeader {
sdlFunctionPtr function;
zval function_name;
Expand Down Expand Up @@ -63,7 +60,6 @@ static xmlNodePtr serialize_parameter(sdlParamPtr param,zval *param_val,int inde
static xmlNodePtr serialize_zval(zval *val, sdlParamPtr param, char *paramName, int style, xmlNodePtr parent);

static void delete_service(void *service);
static void delete_hashtable(void *hashtable);

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

Expand Down Expand Up @@ -134,8 +130,6 @@ static void soap_error_handler(int error_num, zend_string *error_filename, const
} \
}

#define FETCH_TYPEMAP_RES(ss,tmp) ss = (HashTable*) zend_fetch_resource_ex(tmp, "typemap", le_typemap)

#define Z_PARAM_NAME_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 0))
#define Z_PARAM_DATA_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 1))

Expand Down Expand Up @@ -454,11 +448,6 @@ PHP_RINIT_FUNCTION(soap)
return SUCCESS;
}

static void delete_hashtable_res(zend_resource *res)
{
delete_hashtable(res->ptr);
}

PHP_MINIT_FUNCTION(soap)
{
/* TODO: add ini entry for always use soap errors */
Expand Down Expand Up @@ -489,8 +478,6 @@ PHP_MINIT_FUNCTION(soap)

soap_header_class_entry = register_class_SoapHeader();

le_typemap = zend_register_list_destructors_ex(delete_hashtable_res, NULL, "SOAP table", module_number);

soap_url_class_entry = register_class_Soap_Url();
soap_url_class_entry->create_object = soap_url_object_create;
soap_url_class_entry->default_object_handlers = &soap_url_object_handlers;
Expand Down Expand Up @@ -2148,8 +2135,7 @@ PHP_METHOD(SoapClient, __construct)
if (typemap_ht) {
HashTable *typemap = soap_create_typemap(sdl, typemap_ht);
if (typemap) {
zend_resource *res = zend_register_resource(typemap, le_typemap);
ZVAL_RES(Z_CLIENT_TYPEMAP_P(this_ptr), res);
ZVAL_ARR(Z_CLIENT_TYPEMAP_P(this_ptr), typemap);
}
}
SOAP_CLIENT_END_CODE();
Expand Down Expand Up @@ -2281,8 +2267,8 @@ static void do_soap_call(zend_execute_data *execute_data,
}

tmp = Z_CLIENT_TYPEMAP_P(this_ptr);
if (Z_TYPE_P(tmp) == IS_RESOURCE) {
FETCH_TYPEMAP_RES(typemap, tmp);
if (Z_TYPE_P(tmp) == IS_ARRAY) {
typemap = Z_ARR_P(tmp);
}

clear_soap_fault(this_ptr);
Expand Down Expand Up @@ -4478,10 +4464,4 @@ static void delete_service(void *data) /* {{{ */
}
/* }}} */

static void delete_hashtable(void *data) /* {{{ */
{
HashTable *ht = (HashTable*)data;
zend_hash_destroy(ht);
efree(ht);
}
/* }}} */
3 changes: 1 addition & 2 deletions ext/soap/soap.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,7 @@ class SoapClient
private bool $trace = false;
private ?int $compression = null;
private ?Soap\Sdl $sdl = null;
/** @var resource|null */
private $typemap = null;
private ?array $typemap = null;
/** @var resource|null */
private $httpsocket = null;
private ?Soap\Url $httpurl = null;
Expand Down
4 changes: 2 additions & 2 deletions ext/soap/soap_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit aea77f2

Please sign in to comment.