Gentoo Archives: gentoo-commits

From: Brian Evans <grknight@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-php/pecl-stomp/, dev-php/pecl-stomp/files/
Date: Thu, 15 Apr 2021 16:24:29
Message-Id: 1618503829.fe85ba0a6989670e9eafeda71822dddd1ef029a6.grknight@gentoo
1 commit: fe85ba0a6989670e9eafeda71822dddd1ef029a6
2 Author: Brian Evans <grknight <AT> gentoo <DOT> org>
3 AuthorDate: Thu Apr 15 16:23:49 2021 +0000
4 Commit: Brian Evans <grknight <AT> gentoo <DOT> org>
5 CommitDate: Thu Apr 15 16:23:49 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fe85ba0a
7
8 dev-php/pecl-stomp: Add patch for PHP 8 support from upstream
9
10 Signed-off-by: Brian Evans <grknight <AT> gentoo.org>
11
12 .../pecl-stomp/files/pecl-stomp-2.0.2-php8.patch | 369 +++++++++++++++++++++
13 dev-php/pecl-stomp/pecl-stomp-2.0.2-r1.ebuild | 6 +-
14 2 files changed, 373 insertions(+), 2 deletions(-)
15
16 diff --git a/dev-php/pecl-stomp/files/pecl-stomp-2.0.2-php8.patch b/dev-php/pecl-stomp/files/pecl-stomp-2.0.2-php8.patch
17 new file mode 100644
18 index 00000000000..9d38a2d7ff4
19 --- /dev/null
20 +++ b/dev-php/pecl-stomp/files/pecl-stomp-2.0.2-php8.patch
21 @@ -0,0 +1,369 @@
22 +From 13681a79d9389603d9788802f0a114671a753df1 Mon Sep 17 00:00:00 2001
23 +From: Remi Collet <remi@××××××××.net>
24 +Date: Fri, 25 Sep 2020 16:06:39 +0200
25 +Subject: [PATCH] Fix compatibility with PHP 8 - cleanup remaining TSRMLS
26 + macros - fix read/update_property parameters - adapt test suite for exception
27 + in arg. parsing - fix callback
28 +
29 +---
30 + php_stomp.c | 38 ++++++++++++++++++++--------------
31 + stomp.c | 6 +++---
32 + stomp.h | 4 ++--
33 + tests/003-connect/003.phpt | 2 +-
34 + tests/005-close/001.phpt | 8 +++++--
35 + tests/007-subscribe/001.phpt | 2 +-
36 + tests/008-unsubscribe/001.phpt | 2 +-
37 + tests/010-timeout/001.phpt | 24 ++++++++++++---------
38 + tests/010-timeout/002.phpt | 26 ++++++++++++++---------
39 + 9 files changed, 67 insertions(+), 45 deletions(-)
40 +
41 +diff --git a/php_stomp.c b/php_stomp.c
42 +index 0dcefed..b99a9ff 100644
43 +--- a/php_stomp.c
44 ++++ b/php_stomp.c
45 +@@ -97,7 +97,7 @@
46 + zval _object, *object = &_object; \
47 + THROW_STOMP_EXCEPTION(object, errno, msg) \
48 + if (details) { \
49 +- zend_update_property_string(stomp_ce_exception, object, "details", sizeof("details")-1, (char *) details ); \
50 ++ zend_update_property_string(stomp_ce_exception, OBJ_FOR_PROP(object), "details", sizeof("details")-1, (char *) details ); \
51 + } \
52 + }
53 +
54 +@@ -107,6 +107,12 @@
55 + #define STOMP_URL_STR(a) ZSTR_VAL(a)
56 + #endif
57 +
58 ++#if PHP_VERSION_ID < 80000
59 ++#define OBJ_FOR_PROP(zv) (zv)
60 ++#else
61 ++#define OBJ_FOR_PROP(zv) Z_OBJ_P(zv)
62 ++#endif
63 ++
64 + static int le_stomp;
65 + static zend_object_handlers stomp_obj_handlers;
66 +
67 +@@ -564,7 +570,7 @@ PHP_FUNCTION(stomp_connect)
68 + zval excobj;
69 + THROW_STOMP_EXCEPTION(&excobj, stomp->errnum, stomp->error);
70 + if (stomp->error_details) {
71 +- zend_update_property_string(stomp_ce_exception, &excobj, "details", sizeof("details")-1, stomp->error_details );
72 ++ zend_update_property_string(stomp_ce_exception, OBJ_FOR_PROP(&excobj), "details", sizeof("details")-1, stomp->error_details );
73 + }
74 + return;
75 + }
76 +@@ -578,7 +584,7 @@ PHP_FUNCTION(stomp_connect)
77 + if ((error_msg = zend_hash_str_find(res->headers, ZEND_STRL("message"))) != NULL) {
78 + THROW_STOMP_EXCEPTION(&excobj, 0, ZSTR_VAL(Z_STR_P(error_msg)));
79 + if (res->body) {
80 +- zend_update_property_string(stomp_ce_exception, &excobj, "details", sizeof("details")-1, (char *) res->body );
81 ++ zend_update_property_string(stomp_ce_exception, OBJ_FOR_PROP(&excobj), "details", sizeof("details")-1, (char *) res->body );
82 + }
83 + }
84 + stomp_free_frame(res);
85 +@@ -735,17 +741,17 @@ PHP_FUNCTION(stomp_send)
86 + frame.body_length = Z_STRLEN_P(msg);
87 + } else if (Z_TYPE_P(msg) == IS_OBJECT && instanceof_function(Z_OBJCE_P(msg), stomp_ce_frame )) {
88 + zval *frame_obj_prop = NULL;
89 +- frame_obj_prop = zend_read_property(stomp_ce_frame, msg, "command", sizeof("command")-1, 1, &rv);
90 ++ frame_obj_prop = zend_read_property(stomp_ce_frame, OBJ_FOR_PROP(msg), "command", sizeof("command")-1, 1, &rv);
91 + if (Z_TYPE_P(frame_obj_prop) == IS_STRING) {
92 + frame.command = Z_STRVAL_P(frame_obj_prop);
93 + frame.command_length = Z_STRLEN_P(frame_obj_prop);
94 + }
95 +- frame_obj_prop = zend_read_property(stomp_ce_frame, msg, "body", sizeof("body")-1, 1, &rv);
96 ++ frame_obj_prop = zend_read_property(stomp_ce_frame, OBJ_FOR_PROP(msg), "body", sizeof("body")-1, 1, &rv);
97 + if (Z_TYPE_P(frame_obj_prop) == IS_STRING) {
98 + frame.body = Z_STRVAL_P(frame_obj_prop);
99 + frame.body_length = Z_STRLEN_P(frame_obj_prop);
100 + }
101 +- frame_obj_prop = zend_read_property(stomp_ce_frame, msg, "headers", sizeof("headers")-1, 1, &rv);
102 ++ frame_obj_prop = zend_read_property(stomp_ce_frame, OBJ_FOR_PROP(msg), "headers", sizeof("headers")-1, 1, &rv);
103 + if (Z_TYPE_P(frame_obj_prop) == IS_ARRAY) {
104 + FRAME_HEADER_FROM_HASHTABLE(frame.headers, Z_ARRVAL_P(frame_obj_prop));
105 + }
106 +@@ -930,7 +936,7 @@ PHP_FUNCTION(stomp_read_frame)
107 + zval excobj;
108 + THROW_STOMP_EXCEPTION(&excobj, 0, Z_STRVAL_P(error_msg));
109 + if (res->body) {
110 +- zend_update_property_string(stomp_ce_exception, &excobj, ZEND_STRL("details"), (char *)res->body );
111 ++ zend_update_property_string(stomp_ce_exception, OBJ_FOR_PROP(&excobj), ZEND_STRL("details"), (char *)res->body );
112 + }
113 + stomp_free_frame(res);
114 + RETURN_FALSE;
115 +@@ -968,10 +974,11 @@ PHP_FUNCTION(stomp_read_frame)
116 + ZVAL_NULL(&body);
117 + }
118 +
119 ++ memset(&fci, 0, sizeof(fci));
120 ++ memset(&fcc, 0, sizeof(fcc));
121 + fci.size = sizeof(fci);
122 + #if (PHP_MAJOR_VERSION == 7 && PHP_MINOR_VERSION == 0)
123 + fci.function_table = &ce->function_table;
124 +- fci.symbol_table = NULL;
125 + #endif
126 + /* PARAMS */
127 + fci.param_count = 3;
128 +@@ -983,8 +990,9 @@ PHP_FUNCTION(stomp_read_frame)
129 + ZVAL_UNDEF(&fci.function_name);
130 + fci.object = Z_OBJ_P(return_value);
131 + fci.retval = &retval;
132 ++#if PHP_VERSION_ID < 80000
133 + fci.no_separation = 1;
134 +-
135 ++#endif
136 + #if PHP_VERSION_ID < 70300
137 + fcc.initialized = 1;
138 + #endif
139 +@@ -997,7 +1005,7 @@ PHP_FUNCTION(stomp_read_frame)
140 + fcc.object = Z_OBJ_P(return_value);
141 +
142 + if (zend_call_function(&fci, &fcc ) == FAILURE) {
143 +- zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 , "Could not execute %s::%s()", ZSTR_VAL(ce->name), ZSTR_VAL(ce->constructor->common.function_name));
144 ++ zend_throw_exception_ex(zend_exception_get_default(), 0 , "Could not execute %s::%s()", ZSTR_VAL(ce->name), ZSTR_VAL(ce->constructor->common.function_name));
145 + } else {
146 + zval_ptr_dtor(&retval);
147 + }
148 +@@ -1127,7 +1135,7 @@ static void _php_stomp_acknowledgment(INTERNAL_FUNCTION_PARAMETERS, char *cmd) {
149 + } else if (Z_TYPE_P(msg) == IS_OBJECT && instanceof_function(Z_OBJCE_P(msg), stomp_ce_frame )) {
150 + zval *frame_obj_prop, rv;
151 +
152 +- frame_obj_prop = zend_read_property(stomp_ce_frame, msg, "headers", sizeof("headers")-1, 1, &rv);
153 ++ frame_obj_prop = zend_read_property(stomp_ce_frame, OBJ_FOR_PROP(msg), "headers", sizeof("headers")-1, 1, &rv);
154 + if (Z_TYPE_P(frame_obj_prop) == IS_ARRAY) {
155 + FRAME_HEADER_FROM_HASHTABLE(frame.headers, Z_ARRVAL_P(frame_obj_prop));
156 + }
157 +@@ -1257,13 +1265,13 @@ PHP_METHOD(stompframe, __construct)
158 + }
159 +
160 + if (command_length > 0) {
161 +- zend_update_property_stringl(stomp_ce_frame, object, "command", sizeof("command")-1, command, command_length );
162 ++ zend_update_property_stringl(stomp_ce_frame, OBJ_FOR_PROP(object), "command", sizeof("command")-1, command, command_length );
163 + }
164 + if (headers) {
165 +- zend_update_property(stomp_ce_frame, object, "headers", sizeof("headers")-1, headers );
166 ++ zend_update_property(stomp_ce_frame, OBJ_FOR_PROP(object), "headers", sizeof("headers")-1, headers );
167 + }
168 + if (body_length > 0) {
169 +- zend_update_property_stringl(stomp_ce_frame, object, "body", sizeof("body")-1, body, body_length );
170 ++ zend_update_property_stringl(stomp_ce_frame, OBJ_FOR_PROP(object), "body", sizeof("body")-1, body, body_length );
171 + }
172 + }
173 + /* }}} */
174 +@@ -1273,7 +1281,7 @@ PHP_METHOD(stompframe, __construct)
175 + PHP_METHOD(stompexception, getDetails)
176 + {
177 + zval *object = getThis();
178 +- zval rv, *details = zend_read_property(stomp_ce_exception, object, "details", sizeof("details")-1, 1, &rv);
179 ++ zval rv, *details = zend_read_property(stomp_ce_exception, OBJ_FOR_PROP(object), "details", sizeof("details")-1, 1, &rv);
180 + RETURN_STR(zval_get_string(details));
181 + }
182 + /* }}} */
183 +diff --git a/stomp.c b/stomp.c
184 +index d83a4e6..6e77ede 100644
185 +--- a/stomp.c
186 ++++ b/stomp.c
187 +@@ -36,7 +36,7 @@ extern zend_class_entry *stomp_ce_exception;
188 +
189 + /* {{{ DEBUG */
190 + #if PHP_DEBUG
191 +-static void print_stomp_frame(stomp_frame_t *frame TSRMLS_DC) {
192 ++static void print_stomp_frame(stomp_frame_t *frame) {
193 + php_printf("------ START FRAME ------\n");
194 + php_printf("%s\n", frame->command);
195 + /* Headers */
196 +@@ -188,7 +188,7 @@ int stomp_writable(stomp_t *stomp)
197 +
198 + /* {{{ stomp_connect
199 + */
200 +-int stomp_connect(stomp_t *stomp, const char *host, unsigned short port TSRMLS_DC)
201 ++int stomp_connect(stomp_t *stomp, const char *host, unsigned short port)
202 + {
203 + char error[1024];
204 + socklen_t size;
205 +@@ -299,7 +299,7 @@ void stomp_close(stomp_t *stomp)
206 +
207 + /* {{{ stomp_send
208 + */
209 +-int stomp_send(stomp_t *stomp, stomp_frame_t *frame TSRMLS_DC)
210 ++int stomp_send(stomp_t *stomp, stomp_frame_t *frame)
211 + {
212 + smart_str buf = {0};
213 +
214 +diff --git a/stomp.h b/stomp.h
215 +index 1a422b7..e4d02b3 100644
216 +--- a/stomp.h
217 ++++ b/stomp.h
218 +@@ -81,9 +81,9 @@ typedef struct _stomp {
219 + } stomp_t;
220 +
221 + stomp_t *stomp_init();
222 +-int stomp_connect(stomp_t *stomp, const char *host, unsigned short port TSRMLS_DC);
223 ++int stomp_connect(stomp_t *stomp, const char *host, unsigned short port);
224 + void stomp_close(stomp_t *stomp);
225 +-int stomp_send(stomp_t *connection, stomp_frame_t *frame TSRMLS_DC);
226 ++int stomp_send(stomp_t *connection, stomp_frame_t *frame);
227 + stomp_frame_t *stomp_read_frame_ex(stomp_t *connection, int use_stack);
228 + int stomp_valid_receipt(stomp_t *connection, stomp_frame_t *frame);
229 + int stomp_select_ex(stomp_t *connection, const long int sec, const long int usec);
230 +diff --git a/tests/003-connect/003.phpt b/tests/003-connect/003.phpt
231 +index b3de8d6..ba60e15 100644
232 +--- a/tests/003-connect/003.phpt
233 ++++ b/tests/003-connect/003.phpt
234 +@@ -2,7 +2,7 @@
235 + Test stomp_connect() - Test error on CONNECT
236 + --SKIPIF--
237 + <?php
238 +-include "../skipif.inc"
239 ++include dirname(__DIR__) . "/skipif.inc";
240 + ?>
241 + --FILE--
242 + <?php
243 +diff --git a/tests/005-close/001.phpt b/tests/005-close/001.phpt
244 +index 0a23a59..77cc014 100644
245 +--- a/tests/005-close/001.phpt
246 ++++ b/tests/005-close/001.phpt
247 +@@ -6,7 +6,11 @@ include dirname(__DIR__) . "/skipif.inc";
248 + ?>
249 + --FILE--
250 + <?php
251 +-stomp_close(null);
252 ++try {
253 ++ stomp_close(null);
254 ++} catch (TypeError $e) {
255 ++ echo $e->getMessage() . PHP_EOL;
256 ++}
257 + ?>
258 + --EXPECTF--
259 +-Warning: stomp_close() expects parameter 1 to be resource, null given in %s on line %d
260 ++%stomp_close()%s1%s null %s
261 +diff --git a/tests/007-subscribe/001.phpt b/tests/007-subscribe/001.phpt
262 +index 8d190dd..494471c 100644
263 +--- a/tests/007-subscribe/001.phpt
264 ++++ b/tests/007-subscribe/001.phpt
265 +@@ -16,7 +16,7 @@ $s->subscribe('/queue/test', 'string');
266 + --EXPECTF--
267 + Warning: Stomp::subscribe(): Destination can not be empty in %s007-subscribe%c001.php on line %d
268 +
269 +-Fatal error: Uncaught TypeError: Argument 2 passed to Stomp::subscribe() must be of the type array, string given in %s007-subscribe%c001.php:%d
270 ++Fatal error: Uncaught TypeError: %s, string given in %s007-subscribe%c001.php:%d
271 + Stack trace:
272 + #0 %s001.php(%d): Stomp->subscribe('/queue/test', 'string')
273 + #1 {main}
274 +diff --git a/tests/008-unsubscribe/001.phpt b/tests/008-unsubscribe/001.phpt
275 +index c1200eb..7d1b50f 100644
276 +--- a/tests/008-unsubscribe/001.phpt
277 ++++ b/tests/008-unsubscribe/001.phpt
278 +@@ -17,7 +17,7 @@ $s->unsubscribe('/queue/test', 'string');
279 + --EXPECTF--
280 + Warning: Stomp::unsubscribe(): Destination can not be empty in %s008-unsubscribe%c001.php on line %d
281 +
282 +-Fatal error: Uncaught TypeError: Argument 2 passed to Stomp::unsubscribe() must be of the type array, string given in %s008-unsubscribe%c001.php:%d
283 ++Fatal error: Uncaught TypeError: %s2%s string given in %s008-unsubscribe%c001.php:%d
284 + Stack trace:
285 + #0 %s(%d): Stomp->unsubscribe('/queue/test', 'string')
286 + #1 {main}
287 +diff --git a/tests/010-timeout/001.phpt b/tests/010-timeout/001.phpt
288 +index 7389f70..b9886db 100644
289 +--- a/tests/010-timeout/001.phpt
290 ++++ b/tests/010-timeout/001.phpt
291 +@@ -25,13 +25,21 @@ var_dump($s->setReadTimeout(10, 5));
292 + // Third test, read supposed to return 10.5
293 + var_dump($s->getReadTimeout());
294 +
295 +-// Set read timout with the first param as a string, supposed to trigger a warning
296 +-var_dump($s->setReadTimeout(''));
297 ++try {
298 ++ // Set read timout with the first param as a string, supposed to trigger a warning/exception
299 ++ var_dump($s->setReadTimeout(''));
300 ++} catch (TypeError $e) {
301 ++ echo $e->getMessage() . PHP_EOL;
302 ++}
303 + // Fourth test, read supposed to get the last value set : 10.5
304 + var_dump($s->getReadTimeout());
305 +
306 +-// Set read timout with the second param as a string, supposed to trigger a warning
307 +-var_dump($s->setReadTimeout(10, ''));
308 ++try {
309 ++ // Set read timout with the second param as a string, supposed to trigger a warning/exception
310 ++ var_dump($s->setReadTimeout(10, ''));
311 ++} catch (TypeError $e) {
312 ++ echo $e->getMessage() . PHP_EOL;
313 ++}
314 + // Fourth test, read supposed to get the last value set : 10.5
315 + var_dump($s->getReadTimeout());
316 +
317 +@@ -64,18 +72,14 @@ array(2) {
318 + ["usec"]=>
319 + int(5)
320 + }
321 +-
322 +-Warning: Stomp::setReadTimeout() expects parameter 1 to be long, string given in %s on line %d
323 +-NULL
324 ++%AStomp::setReadTimeout()%s1%s string given%A
325 + array(2) {
326 + ["sec"]=>
327 + int(10)
328 + ["usec"]=>
329 + int(5)
330 + }
331 +-
332 +-Warning: Stomp::setReadTimeout() expects parameter 2 to be long, string given in %s on line %d
333 +-NULL
334 ++%AStomp::setReadTimeout()%s2%s string given%A
335 + array(2) {
336 + ["sec"]=>
337 + int(10)
338 +diff --git a/tests/010-timeout/002.phpt b/tests/010-timeout/002.phpt
339 +index a6a9b4a..c22dedf 100644
340 +--- a/tests/010-timeout/002.phpt
341 ++++ b/tests/010-timeout/002.phpt
342 +@@ -25,13 +25,23 @@ var_dump(stomp_set_read_timeout($link, 10, 5));
343 + // Third test, read supposed to return 10.5
344 + var_dump(stomp_get_read_timeout($link));
345 +
346 +-// Set read timout with the first param as a string, supposed to trigger a warning
347 +-var_dump(stomp_set_read_timeout($link, ''));
348 ++try {
349 ++ // Set read timout with the first param as a string, supposed to trigger a warning on PHP 7
350 ++ // supposed to trigger an exception on PHP 8
351 ++ var_dump(stomp_set_read_timeout($link, ''));
352 ++} catch (TypeError $e) {
353 ++ echo $e->getMessage() . PHP_EOL;
354 ++}
355 + // Fourth test, read supposed to get the last value set : 10.5
356 + var_dump(stomp_get_read_timeout($link));
357 +
358 +-// Set read timout with the second param as a string, supposed to trigger a warning
359 +-var_dump(stomp_set_read_timeout($link, 10, ''));
360 ++try {
361 ++ // Set read timout with the second param as a string, supposed to trigger a warning on PHP 7
362 ++ // supposed to trigger an exception on PHP 8
363 ++ var_dump(stomp_set_read_timeout($link, 10, ''));
364 ++} catch (TypeError $e) {
365 ++ echo $e->getMessage() . PHP_EOL;
366 ++}
367 + // Fourth test, read supposed to get the last value set : 10.5
368 + var_dump(stomp_get_read_timeout($link));
369 +
370 +@@ -64,18 +74,14 @@ array(2) {
371 + ["usec"]=>
372 + int(5)
373 + }
374 +-
375 +-Warning: stomp_set_read_timeout() expects parameter 2 to be long, string given in %s on line %d
376 +-NULL
377 ++%Astomp_set_read_timeout()%s2%S string given%A
378 + array(2) {
379 + ["sec"]=>
380 + int(10)
381 + ["usec"]=>
382 + int(5)
383 + }
384 +-
385 +-Warning: stomp_set_read_timeout() expects parameter 3 to be long, string given in %s on line %d
386 +-NULL
387 ++%Astomp_set_read_timeout()%s3%s string given%A
388 + array(2) {
389 + ["sec"]=>
390 + int(10)
391
392 diff --git a/dev-php/pecl-stomp/pecl-stomp-2.0.2-r1.ebuild b/dev-php/pecl-stomp/pecl-stomp-2.0.2-r1.ebuild
393 index bc5c1a2e4ad..9a975221aa4 100644
394 --- a/dev-php/pecl-stomp/pecl-stomp-2.0.2-r1.ebuild
395 +++ b/dev-php/pecl-stomp/pecl-stomp-2.0.2-r1.ebuild
396 @@ -1,9 +1,9 @@
397 -# Copyright 1999-2020 Gentoo Authors
398 +# Copyright 1999-2021 Gentoo Authors
399 # Distributed under the terms of the GNU General Public License v2
400
401 EAPI=7
402
403 -USE_PHP="php7-2 php7-3 php7-4"
404 +USE_PHP="php7-3 php7-4 php8-0"
405 PHP_EXT_NAME="stomp"
406 PHP_EXT_NEEDED_USE="ssl(-)?"
407 DOCS=( CREDITS doc/classes.php doc/functions.php )
408 @@ -20,6 +20,8 @@ RESTRICT="!test? ( test )"
409
410 BDEPEND="virtual/pkgconfig"
411
412 +PATCHES=( "${FILESDIR}/pecl-stomp-2.0.2-php8.patch" )
413 +
414 src_configure() {
415 local PHP_EXT_ECONF_ARGS=(
416 --enable-stomp