From 789de276603ca54cf85c958bf996c4faedf73223 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Fri, 4 Jul 2025 12:13:08 +0200 Subject: [PATCH 1/2] Use php_format_date instead of php_std_date - php_format_date exists in 7.4+ - php_std_date removed in 8.5 x --- amqp_connection_resource.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/amqp_connection_resource.c b/amqp_connection_resource.c index 8809a20b..eaf857e7 100644 --- a/amqp_connection_resource.c +++ b/amqp_connection_resource.c @@ -26,7 +26,7 @@ #endif #include "php.h" -#include "ext/standard/datetime.h" +#include "ext/date/php_date.h" #include "zend_exceptions.h" #ifdef PHP_WIN32 @@ -470,8 +470,8 @@ amqp_connection_resource *connection_resource_constructor(amqp_connection_params { struct timeval tv = {0}; struct timeval *tv_ptr = &tv; + zend_string *std_datetime; - char *std_datetime; amqp_table_entry_t client_properties_entries[4]; amqp_table_t client_properties_table; @@ -581,8 +581,6 @@ amqp_connection_resource *connection_resource_constructor(amqp_connection_params return NULL; } - std_datetime = php_std_date(time(NULL)); - client_properties_entries[0].key = amqp_cstring_bytes("type"); client_properties_entries[0].value.kind = AMQP_FIELD_KIND_UTF8; client_properties_entries[0].value.value.bytes = amqp_cstring_bytes("php-amqp extension"); @@ -597,7 +595,8 @@ amqp_connection_resource *connection_resource_constructor(amqp_connection_params client_properties_entries[3].key = amqp_cstring_bytes("connection started"); client_properties_entries[3].value.kind = AMQP_FIELD_KIND_UTF8; - client_properties_entries[3].value.value.bytes = amqp_cstring_bytes(std_datetime); + std_datetime = php_format_date("D, d M Y H:i:s \\G\\M\\T", sizeof("D, d M Y H:i:s \\G\\M\\T")-1, time(NULL), 0); + client_properties_entries[3].value.value.bytes = amqp_cstring_bytes(ZSTR_VAL(std_datetime)); client_properties_table.entries = client_properties_entries; client_properties_table.num_entries = sizeof(client_properties_entries) / sizeof(amqp_table_entry_t); @@ -632,7 +631,7 @@ amqp_connection_resource *connection_resource_constructor(amqp_connection_params params->password ); - efree(std_datetime); + zend_string_release(std_datetime); if (AMQP_RESPONSE_NORMAL != res.reply_type) { char *message = NULL, *long_message = NULL; From 32c799b2f4182e4d7f2ef99cdbd9df3d6f0c2678 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 15 Jul 2025 14:50:40 +0200 Subject: [PATCH 2/2] use zend_ce_exception --- amqp.c | 2 +- amqp_queue.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/amqp.c b/amqp.c index ef04488d..84a87b7b 100644 --- a/amqp.c +++ b/amqp.c @@ -276,7 +276,7 @@ static PHP_MINIT_FUNCTION(amqp) /* {{{ */ /* Exceptions */ INIT_CLASS_ENTRY(ce, "AMQPException", NULL); - amqp_exception_class_entry = zend_register_internal_class_ex(&ce, zend_exception_get_default()); + amqp_exception_class_entry = zend_register_internal_class_ex(&ce, zend_ce_exception); INIT_CLASS_ENTRY(ce, "AMQPConnectionException", NULL); amqp_connection_exception_class_entry = zend_register_internal_class_ex(&ce, amqp_exception_class_entry); diff --git a/amqp_queue.c b/amqp_queue.c index eeeec3df..48287fa1 100644 --- a/amqp_queue.c +++ b/amqp_queue.c @@ -754,7 +754,7 @@ static PHP_METHOD(amqp_queue_class, consume) ZVAL_UNDEF(&exception); object_init_ex(&exception, amqp_envelope_exception_class_entry); zend_update_property_string( - zend_exception_get_default(), + zend_ce_exception, PHP_AMQP_COMPAT_OBJ_P(&exception), ZEND_STRL("message"), "Orphaned envelope"