summaryrefslogtreecommitdiffstats
path: root/595.patch
blob: f274a417d7b8ce77616a4a4b65235bc43698431e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
From 789de276603ca54cf85c958bf996c4faedf73223 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Fri, 4 Jul 2025 12:13:08 +0200
Subject: [PATCH 1/3] 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 <remi@remirepo.net>
Date: Tue, 15 Jul 2025 14:50:40 +0200
Subject: [PATCH 2/3] 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"

From 977449987412a3d5c59a036dbab8b6d67764bb3e Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Mon, 29 Sep 2025 07:49:28 +0200
Subject: [PATCH 3/3] Silent the "not representable as an int" warning

---
 tests/amqpconnection_validation.phpt | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tests/amqpconnection_validation.phpt b/tests/amqpconnection_validation.phpt
index 9f67cf67..bb1790c0 100644
--- a/tests/amqpconnection_validation.phpt
+++ b/tests/amqpconnection_validation.phpt
@@ -26,7 +26,12 @@ foreach ($parameters as $args) {
     list($prop, $setter, $getter, $values) = $args;
     foreach ($values as $value) {
         try {
-            $con1 = new AMQPConnection([$prop => $value]);
+            if (in_array($prop, ['frame_max', 'heartbeat'])) {
+                // Silent the "not representable as an int" warning
+                $con1 = @new AMQPConnection([$prop => $value]);
+            } else {
+                $con1 = new AMQPConnection([$prop => $value]);
+            }
             echo $getter . " after constructor: ";
             echo $con1->{$getter}();
             echo PHP_EOL;
@@ -109,4 +114,4 @@ AMQPConnectionException: Parameter 'heartbeat' is out of range.
 AMQPConnectionException: Parameter 'heartbeat' is out of range.
 getHeartbeatInterval after constructor: 250
 getHeartbeatInterval after constructor: 0
-==DONE==
\ No newline at end of file
+==DONE==