From 9917e7ab545305596497cd85e359b6e332b6972b Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Thu, 21 Nov 2024 13:20:24 +0100 Subject: [PATCH] Compatibility with newest arginfo gen_stub from PHP 8.4 Signed-off-by: Bob Weinand --- ext/compatibility.h | 8 +++++ ext/ddtrace.c | 2 ++ ext/ddtrace_arginfo.h | 48 +++++++++-------------------- ext/hook/uhook_arginfo.h | 8 ++--- ext/hook/uhook_attributes.c | 2 +- ext/hook/uhook_attributes_arginfo.h | 5 ++- 6 files changed, 30 insertions(+), 43 deletions(-) diff --git a/ext/compatibility.h b/ext/compatibility.h index f85d747ea3f..443822cb36e 100644 --- a/ext/compatibility.h +++ b/ext/compatibility.h @@ -96,6 +96,8 @@ static inline zend_long zval_get_long(zval *op) { #endif enum { + ZEND_STR_NAME, + ZEND_STR_RESOURCE, ZEND_STR_TRACE, ZEND_STR_LINE, ZEND_STR_FILE, @@ -625,6 +627,12 @@ static zend_always_inline zend_result zend_call_function_with_return_value(zend_ #else #define hasThis() (Z_TYPE_P(ZEND_THIS) == IS_OBJECT) #endif + +static inline zend_class_entry *zend_register_internal_class_with_flags(zend_class_entry *class_entry, zend_class_entry *parent_ce, uint32_t ce_flags) { + zend_class_entry *register_class = zend_register_internal_class_ex(class_entry, parent_ce); + register_class->ce_flags |= ce_flags; + return register_class; +} #endif #endif // DD_COMPATIBILITY_H diff --git a/ext/ddtrace.c b/ext/ddtrace.c index c4d5083a376..6a352ddc5be 100644 --- a/ext/ddtrace.c +++ b/ext/ddtrace.c @@ -1305,6 +1305,8 @@ static void dd_disable_if_incompatible_sapi_detected(void) { #if PHP_VERSION_ID < 70100 zend_string *ddtrace_known_strings[ZEND_STR__LAST]; void ddtrace_init_known_strings(void) { + ddtrace_known_strings[ZEND_STR_NAME] = zend_string_init_interned(ZEND_STRL("name"), 1); + ddtrace_known_strings[ZEND_STR_RESOURCE] = zend_string_init_interned(ZEND_STRL("resource"), 1); ddtrace_known_strings[ZEND_STR_TRACE] = zend_string_init_interned(ZEND_STRL("trace"), 1); ddtrace_known_strings[ZEND_STR_LINE] = zend_string_init_interned(ZEND_STRL("line"), 1); ddtrace_known_strings[ZEND_STR_FILE] = zend_string_init_interned(ZEND_STRL("file"), 1); diff --git a/ext/ddtrace_arginfo.h b/ext/ddtrace_arginfo.h index a68293da301..8766e5292ed 100644 --- a/ext/ddtrace_arginfo.h +++ b/ext/ddtrace_arginfo.h @@ -477,10 +477,6 @@ static const zend_function_entry class_DDTrace_SpanLink_methods[] = { ZEND_FE_END }; -static const zend_function_entry class_DDTrace_GitMetadata_methods[] = { - ZEND_FE_END -}; - static const zend_function_entry class_DDTrace_SpanData_methods[] = { ZEND_ME(DDTrace_SpanData, getDuration, arginfo_class_DDTrace_SpanData_getDuration, ZEND_ACC_PUBLIC) ZEND_ME(DDTrace_SpanData, getStartTime, arginfo_class_DDTrace_SpanData_getStartTime, ZEND_ACC_PUBLIC) @@ -489,14 +485,6 @@ static const zend_function_entry class_DDTrace_SpanData_methods[] = { ZEND_FE_END }; -static const zend_function_entry class_DDTrace_RootSpanData_methods[] = { - ZEND_FE_END -}; - -static const zend_function_entry class_DDTrace_SpanStack_methods[] = { - ZEND_FE_END -}; - static const zend_function_entry class_DDTrace_Integration_methods[] = { ZEND_RAW_FENTRY("init", NULL, arginfo_class_DDTrace_Integration_init, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT, NULL, NULL) ZEND_FE_END @@ -523,14 +511,12 @@ static zend_class_entry *register_class_DDTrace_SpanEvent(zend_class_entry *clas zend_class_entry ce, *class_entry; INIT_NS_CLASS_ENTRY(ce, "DDTrace", "SpanEvent", class_DDTrace_SpanEvent_methods); - class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry = zend_register_internal_class_with_flags(&ce, NULL, 0); zend_class_implements(class_entry, 1, class_entry_JsonSerializable); zval property_name_default_value; ZVAL_UNDEF(&property_name_default_value); - zend_string *property_name_name = zend_string_init("name", sizeof("name") - 1, 1); - zend_declare_typed_property(class_entry, property_name_name, &property_name_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_name_name); + zend_declare_typed_property(class_entry, ZSTR_KNOWN(ZEND_STR_NAME), &property_name_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); zval property_attributes_default_value; ZVAL_UNDEF(&property_attributes_default_value); @@ -552,7 +538,7 @@ static zend_class_entry *register_class_DDTrace_ExceptionSpanEvent(zend_class_en zend_class_entry ce, *class_entry; INIT_NS_CLASS_ENTRY(ce, "DDTrace", "ExceptionSpanEvent", class_DDTrace_ExceptionSpanEvent_methods); - class_entry = zend_register_internal_class_ex(&ce, class_entry_DDTrace_SpanEvent); + class_entry = zend_register_internal_class_with_flags(&ce, class_entry_DDTrace_SpanEvent, 0); zval property_exception_default_value; ZVAL_UNDEF(&property_exception_default_value); @@ -569,7 +555,7 @@ static zend_class_entry *register_class_DDTrace_SpanLink(zend_class_entry *class zend_class_entry ce, *class_entry; INIT_NS_CLASS_ENTRY(ce, "DDTrace", "SpanLink", class_DDTrace_SpanLink_methods); - class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry = zend_register_internal_class_with_flags(&ce, NULL, 0); zend_class_implements(class_entry, 1, class_entry_JsonSerializable); zval property_traceId_default_value; @@ -609,8 +595,8 @@ static zend_class_entry *register_class_DDTrace_GitMetadata(void) { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "DDTrace", "GitMetadata", class_DDTrace_GitMetadata_methods); - class_entry = zend_register_internal_class_ex(&ce, NULL); + INIT_NS_CLASS_ENTRY(ce, "DDTrace", "GitMetadata", NULL); + class_entry = zend_register_internal_class_with_flags(&ce, NULL, 0); zval property_commitSha_default_value; ZVAL_EMPTY_STRING(&property_commitSha_default_value); @@ -632,19 +618,15 @@ static zend_class_entry *register_class_DDTrace_SpanData(void) zend_class_entry ce, *class_entry; INIT_NS_CLASS_ENTRY(ce, "DDTrace", "SpanData", class_DDTrace_SpanData_methods); - class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry = zend_register_internal_class_with_flags(&ce, NULL, 0); zval property_name_default_value; ZVAL_EMPTY_STRING(&property_name_default_value); - zend_string *property_name_name = zend_string_init("name", sizeof("name") - 1, 1); - zend_declare_typed_property(class_entry, property_name_name, &property_name_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_name_name); + zend_declare_typed_property(class_entry, ZSTR_KNOWN(ZEND_STR_NAME), &property_name_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); zval property_resource_default_value; ZVAL_EMPTY_STRING(&property_resource_default_value); - zend_string *property_resource_name = zend_string_init("resource", sizeof("resource") - 1, 1); - zend_declare_typed_property(class_entry, property_resource_name, &property_resource_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_resource_name); + zend_declare_typed_property(class_entry, ZSTR_KNOWN(ZEND_STR_RESOURCE), &property_resource_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); zval property_service_default_value; ZVAL_EMPTY_STRING(&property_service_default_value); @@ -672,9 +654,7 @@ static zend_class_entry *register_class_DDTrace_SpanData(void) zval property_type_default_value; ZVAL_EMPTY_STRING(&property_type_default_value); - zend_string *property_type_name = zend_string_init("type", sizeof("type") - 1, 1); - zend_declare_typed_property(class_entry, property_type_name, &property_type_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_type_name); + zend_declare_typed_property(class_entry, ZSTR_KNOWN(ZEND_STR_TYPE), &property_type_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); zval property_meta_default_value; ZVAL_EMPTY_ARRAY(&property_meta_default_value); @@ -740,8 +720,8 @@ static zend_class_entry *register_class_DDTrace_RootSpanData(zend_class_entry *c { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "DDTrace", "RootSpanData", class_DDTrace_RootSpanData_methods); - class_entry = zend_register_internal_class_ex(&ce, class_entry_DDTrace_SpanData); + INIT_NS_CLASS_ENTRY(ce, "DDTrace", "RootSpanData", NULL); + class_entry = zend_register_internal_class_with_flags(&ce, class_entry_DDTrace_SpanData, 0); zval property_origin_default_value; ZVAL_UNDEF(&property_origin_default_value); @@ -805,8 +785,8 @@ static zend_class_entry *register_class_DDTrace_SpanStack(void) { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "DDTrace", "SpanStack", class_DDTrace_SpanStack_methods); - class_entry = zend_register_internal_class_ex(&ce, NULL); + INIT_NS_CLASS_ENTRY(ce, "DDTrace", "SpanStack", NULL); + class_entry = zend_register_internal_class_with_flags(&ce, NULL, 0); zval property_parent_default_value; ZVAL_UNDEF(&property_parent_default_value); diff --git a/ext/hook/uhook_arginfo.h b/ext/hook/uhook_arginfo.h index e0af7e161e9..ddbf22a0fa6 100644 --- a/ext/hook/uhook_arginfo.h +++ b/ext/hook/uhook_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 4b2f667462bc9e7bed94b2c9a479b85f3086b521 */ + * Stub hash: 74ab08e7f09c564fabb646706cb9ba0371026875 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_DDTrace_install_hook, 0, 1, IS_LONG, 0) ZEND_ARG_OBJ_TYPE_MASK(0, target, Closure|Generator, MAY_BE_STRING|MAY_BE_CALLABLE, NULL) @@ -83,7 +83,7 @@ static zend_class_entry *register_class_DDTrace_HookData(void) zend_class_entry ce, *class_entry; INIT_NS_CLASS_ENTRY(ce, "DDTrace", "HookData", class_DDTrace_HookData_methods); - class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry = zend_register_internal_class_with_flags(&ce, NULL, 0); zval property_data_default_value; ZVAL_UNDEF(&property_data_default_value); @@ -99,9 +99,7 @@ static zend_class_entry *register_class_DDTrace_HookData(void) zval property_args_default_value; ZVAL_UNDEF(&property_args_default_value); - zend_string *property_args_name = zend_string_init("args", sizeof("args") - 1, 1); - zend_declare_typed_property(class_entry, property_args_name, &property_args_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ARRAY)); - zend_string_release(property_args_name); + zend_declare_typed_property(class_entry, ZSTR_KNOWN(ZEND_STR_ARGS), &property_args_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ARRAY)); zval property_returned_default_value; ZVAL_UNDEF(&property_returned_default_value); diff --git a/ext/hook/uhook_attributes.c b/ext/hook/uhook_attributes.c index fd2d51f3cd4..e4ff5e52962 100644 --- a/ext/hook/uhook_attributes.c +++ b/ext/hook/uhook_attributes.c @@ -1,9 +1,9 @@ #include #include #include -#include "uhook_attributes_arginfo.h" #include "../ddtrace.h" #include "../configuration.h" +#include "uhook_attributes_arginfo.h" #include "uhook.h" #include diff --git a/ext/hook/uhook_attributes_arginfo.h b/ext/hook/uhook_attributes_arginfo.h index 4c64d765a8b..fb6596cb009 100644 --- a/ext/hook/uhook_attributes_arginfo.h +++ b/ext/hook/uhook_attributes_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 90919c9c350e86acd6fe3c8d06753918d5e0572b */ + * Stub hash: 39cf4bf2cf4b4ec1c18f3ff8643b3ba7b4ad69a1 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DDTrace_Trace___construct, 0, 0, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, name, IS_STRING, 0, "\"\"") @@ -23,8 +23,7 @@ static zend_class_entry *register_class_DDTrace_Trace(void) zend_class_entry ce, *class_entry; INIT_NS_CLASS_ENTRY(ce, "DDTrace", "Trace", class_DDTrace_Trace_methods); - class_entry = zend_register_internal_class_ex(&ce, NULL); - class_entry->ce_flags |= ZEND_ACC_FINAL; + class_entry = zend_register_internal_class_with_flags(&ce, NULL, ZEND_ACC_FINAL); zend_string *attribute_name_Attribute_class_DDTrace_Trace_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, 1); zend_attribute *attribute_Attribute_class_DDTrace_Trace_0 = zend_add_class_attribute(class_entry, attribute_name_Attribute_class_DDTrace_Trace_0, 1);