mirror of
https://github.com/php/php-src.git
synced 2024-11-23 09:54:15 +08:00
Migrate SOAP URL resource to object
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:
parent
02732007f7
commit
44b3cb2a13
@ -135,6 +135,10 @@ PHP 8.4 UPGRADE NOTES
|
||||
. Calling simplexml_import_dom() with a non-XML object now throws a TypeError
|
||||
instead of a ValueError.
|
||||
|
||||
- SOAP:
|
||||
. SoapClient::$httpurl is now a Soap\Url object rather than a resource.
|
||||
Checks using is_resource() (i.e. is_resource($client->httpurl)) should be
|
||||
replaced with checks for null (i.e. $client->httpurl !== null).
|
||||
- SPL:
|
||||
. Out of bounds accesses in SplFixedArray now throw an exception of type
|
||||
OutOfBoundsException instead of RuntimeException. As OutOfBoundsException
|
||||
|
@ -484,8 +484,8 @@ try_again:
|
||||
if (stream != NULL) {
|
||||
php_url *orig;
|
||||
tmp = Z_CLIENT_HTTPURL_P(this_ptr);
|
||||
if (Z_TYPE_P(tmp) == IS_RESOURCE &&
|
||||
(orig = (php_url *) zend_fetch_resource_ex(tmp, "httpurl", le_url)) != NULL &&
|
||||
if (Z_TYPE_P(tmp) == IS_OBJECT && instanceof_function(Z_OBJCE_P(tmp), soap_url_class_entry) &&
|
||||
(orig = Z_SOAP_URL_P(tmp)->url) != NULL &&
|
||||
((use_proxy && !use_ssl) ||
|
||||
(((use_ssl && orig->scheme != NULL && zend_string_equals_literal(orig->scheme, "https")) ||
|
||||
(!use_ssl && orig->scheme == NULL) ||
|
||||
@ -536,9 +536,15 @@ try_again:
|
||||
|
||||
if (stream) {
|
||||
zval *cookies, *login, *password;
|
||||
zend_resource *ret = zend_register_resource(phpurl, le_url);
|
||||
ZVAL_RES(Z_CLIENT_HTTPURL_P(this_ptr), ret);
|
||||
GC_ADDREF(ret);
|
||||
|
||||
zval *url_zval = Z_CLIENT_HTTPURL_P(this_ptr);
|
||||
if (Z_TYPE_P(url_zval) == IS_OBJECT) {
|
||||
zval_ptr_dtor(url_zval);
|
||||
}
|
||||
|
||||
object_init_ex(url_zval, soap_url_class_entry);
|
||||
soap_url_object *url_obj = Z_SOAP_URL_P(url_zval);
|
||||
url_obj->url = phpurl;
|
||||
|
||||
if (context &&
|
||||
(tmp = php_stream_context_get_option(context, "http", "protocol_version")) != NULL &&
|
||||
|
@ -40,8 +40,6 @@
|
||||
# define stricmp strcasecmp
|
||||
#endif
|
||||
|
||||
extern int le_url;
|
||||
|
||||
typedef struct _encodeType encodeType, *encodeTypePtr;
|
||||
typedef struct _encode encode, *encodePtr;
|
||||
|
||||
@ -194,6 +192,7 @@ ZEND_TSRMLS_CACHE_EXTERN()
|
||||
|
||||
extern zend_class_entry* soap_class_entry;
|
||||
extern zend_class_entry* soap_var_class_entry;
|
||||
extern zend_class_entry* soap_url_class_entry;
|
||||
|
||||
void add_soap_fault(zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail);
|
||||
|
||||
@ -253,4 +252,15 @@ static zend_always_inline zval *php_soap_deref(zval *zv) {
|
||||
#define Z_CLIENT_LAST_REQUEST_HEADERS_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 34))
|
||||
#define Z_CLIENT_LAST_RESPONSE_HEADERS_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 35))
|
||||
|
||||
typedef struct soap_url_object {
|
||||
php_url *url;
|
||||
zend_object std;
|
||||
} soap_url_object;
|
||||
|
||||
static inline soap_url_object *soap_url_object_fetch(zend_object *obj)
|
||||
{
|
||||
return (soap_url_object *) ((char *) obj - XtOffsetOf(soap_url_object, std));
|
||||
}
|
||||
|
||||
#define Z_SOAP_URL_P(zv) soap_url_object_fetch(Z_OBJ_P(zv))
|
||||
#endif
|
||||
|
@ -30,7 +30,6 @@
|
||||
|
||||
|
||||
static int le_sdl = 0;
|
||||
int le_url = 0;
|
||||
static int le_typemap = 0;
|
||||
|
||||
typedef struct _soapHeader {
|
||||
@ -65,7 +64,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_url(void *handle);
|
||||
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);
|
||||
@ -178,8 +176,10 @@ static zend_class_entry* soap_fault_class_entry;
|
||||
static zend_class_entry* soap_header_class_entry;
|
||||
static zend_class_entry* soap_param_class_entry;
|
||||
zend_class_entry* soap_var_class_entry;
|
||||
zend_class_entry *soap_url_class_entry;
|
||||
|
||||
static zend_object_handlers soap_server_object_handlers;
|
||||
static zend_object_handlers soap_url_object_handlers;
|
||||
|
||||
typedef struct {
|
||||
soapServicePtr service;
|
||||
@ -206,6 +206,34 @@ static void soap_server_object_free(zend_object *obj) {
|
||||
zend_object_std_dtor(obj);
|
||||
}
|
||||
|
||||
static zend_object *soap_url_object_create(zend_class_entry *ce)
|
||||
{
|
||||
soap_url_object *url_obj = zend_object_alloc(sizeof(soap_url_object), ce);
|
||||
|
||||
zend_object_std_init(&url_obj->std, ce);
|
||||
object_properties_init(&url_obj->std, ce);
|
||||
|
||||
return &url_obj->std;
|
||||
}
|
||||
|
||||
static void soap_url_object_free(zend_object *obj)
|
||||
{
|
||||
soap_url_object *url_obj = soap_url_object_fetch(obj);
|
||||
|
||||
if (url_obj->url) {
|
||||
php_url_free(url_obj->url);
|
||||
url_obj->url = NULL;
|
||||
}
|
||||
|
||||
zend_object_std_dtor(&url_obj->std);
|
||||
}
|
||||
|
||||
static zend_function *soap_url_object_get_constructor(zend_object *object)
|
||||
{
|
||||
zend_throw_error(NULL, "Cannot directly construct Soap\\Url");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
ZEND_DECLARE_MODULE_GLOBALS(soap)
|
||||
|
||||
static void (*old_error_handler)(int, zend_string *, const uint32_t, zend_string *);
|
||||
@ -395,11 +423,6 @@ static void delete_sdl_res(zend_resource *res)
|
||||
delete_sdl(res->ptr);
|
||||
}
|
||||
|
||||
static void delete_url_res(zend_resource *res)
|
||||
{
|
||||
delete_url(res->ptr);
|
||||
}
|
||||
|
||||
static void delete_hashtable_res(zend_resource *res)
|
||||
{
|
||||
delete_hashtable(res->ptr);
|
||||
@ -436,9 +459,19 @@ PHP_MINIT_FUNCTION(soap)
|
||||
soap_header_class_entry = register_class_SoapHeader();
|
||||
|
||||
le_sdl = zend_register_list_destructors_ex(delete_sdl_res, NULL, "SOAP SDL", module_number);
|
||||
le_url = zend_register_list_destructors_ex(delete_url_res, NULL, "SOAP URL", module_number);
|
||||
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;
|
||||
|
||||
memcpy(&soap_url_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
|
||||
soap_url_object_handlers.offset = XtOffsetOf(soap_url_object, std);
|
||||
soap_url_object_handlers.free_obj = soap_url_object_free;
|
||||
soap_url_object_handlers.get_constructor = soap_url_object_get_constructor;
|
||||
soap_url_object_handlers.clone_obj = NULL;
|
||||
soap_url_object_handlers.compare = zend_objects_not_comparable;
|
||||
|
||||
register_soap_symbols(module_number);
|
||||
|
||||
old_error_handler = zend_error_cb;
|
||||
@ -4355,12 +4388,6 @@ static void type_to_string(sdlTypePtr type, smart_str *buf, int level) /* {{{ */
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static void delete_url(void *handle) /* {{{ */
|
||||
{
|
||||
php_url_free((php_url*)handle);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static void delete_service(void *data) /* {{{ */
|
||||
{
|
||||
soapServicePtr service = (soapServicePtr)data;
|
||||
|
File diff suppressed because it is too large
Load Diff
20
ext/soap/soap_arginfo.h
generated
20
ext/soap/soap_arginfo.h
generated
@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: 4dfc98696d4bc5e36610bdf03de906dbae049cf3 */
|
||||
* Stub hash: 038c8f9ba355fba63e661148b48cdf0299b922f6 */
|
||||
|
||||
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")
|
||||
@ -173,6 +173,10 @@ static const zend_function_entry ext_functions[] = {
|
||||
ZEND_FE_END
|
||||
};
|
||||
|
||||
static const zend_function_entry class_Soap_Url_methods[] = {
|
||||
ZEND_FE_END
|
||||
};
|
||||
|
||||
static const zend_function_entry class_SoapParam_methods[] = {
|
||||
ZEND_ME(SoapParam, __construct, arginfo_class_SoapParam___construct, ZEND_ACC_PUBLIC)
|
||||
ZEND_FE_END
|
||||
@ -310,6 +314,17 @@ static void register_soap_symbols(int module_number)
|
||||
REGISTER_LONG_CONSTANT("SOAP_SSL_METHOD_SSLv23", SOAP_SSL_METHOD_SSLv23, CONST_PERSISTENT);
|
||||
}
|
||||
|
||||
static zend_class_entry *register_class_Soap_Url(void)
|
||||
{
|
||||
zend_class_entry ce, *class_entry;
|
||||
|
||||
INIT_NS_CLASS_ENTRY(ce, "Soap", "Url", class_Soap_Url_methods);
|
||||
class_entry = zend_register_internal_class_ex(&ce, NULL);
|
||||
class_entry->ce_flags |= ZEND_ACC_FINAL|ZEND_ACC_NO_DYNAMIC_PROPERTIES|ZEND_ACC_NOT_SERIALIZABLE;
|
||||
|
||||
return class_entry;
|
||||
}
|
||||
|
||||
static zend_class_entry *register_class_SoapParam(void)
|
||||
{
|
||||
zend_class_entry ce, *class_entry;
|
||||
@ -551,7 +566,8 @@ static zend_class_entry *register_class_SoapClient(void)
|
||||
zval property_httpurl_default_value;
|
||||
ZVAL_NULL(&property_httpurl_default_value);
|
||||
zend_string *property_httpurl_name = zend_string_init("httpurl", sizeof("httpurl") - 1, 1);
|
||||
zend_declare_typed_property(class_entry, property_httpurl_name, &property_httpurl_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_NONE(0));
|
||||
zend_string *property_httpurl_class_Soap_Url = zend_string_init("Soap\\\125rl", sizeof("Soap\\\125rl")-1, 1);
|
||||
zend_declare_typed_property(class_entry, property_httpurl_name, &property_httpurl_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_httpurl_class_Soap_Url, 0, MAY_BE_NULL));
|
||||
zend_string_release(property_httpurl_name);
|
||||
|
||||
zval property__login_default_value;
|
||||
|
Loading…
Reference in New Issue
Block a user