1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Migrate SOAP table resource to array

Related to https://wiki.php.net/rfc/resource_to_object_conversion and https://github.com/php/php-tasks/issues/6
This commit is contained in:
Máté Kocsis
2024-05-07 22:57:31 +02:00
committed by Máté Kocsis
parent 48971af482
commit 920591064e
4 changed files with 9 additions and 27 deletions

View File

@@ -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

View File

@@ -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;
@@ -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);
@@ -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))
@@ -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 */
@@ -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;
@@ -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();
@@ -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);
@@ -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);
}
/* }}} */

View File

@@ -537,8 +537,7 @@ namespace {
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;

View File

@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 70fce84457c1e8fc45832d1fa6e7e070c67ad03f */
* Stub hash: 81d0b54b93829f3cd4b12731f6b6ae140b06a0f1 */
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")
@@ -570,7 +570,7 @@ static zend_class_entry *register_class_SoapClient(void)
zval property_typemap_default_value;
ZVAL_NULL(&property_typemap_default_value);
zend_string *property_typemap_name = zend_string_init("typemap", sizeof("typemap") - 1, 1);
zend_declare_typed_property(class_entry, property_typemap_name, &property_typemap_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_NONE(0));
zend_declare_typed_property(class_entry, property_typemap_name, &property_typemap_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ARRAY|MAY_BE_NULL));
zend_string_release(property_typemap_name);
zval property_httpsocket_default_value;