From b0597590e8e346eb7f189549ba33f9804ab26710 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 24 Aug 2020 16:02:58 +0200 Subject: add patch for PHP 8 from https://github.com/zeromq/php-zmq/pull/216 --- 170.patch | 31 ------ 195.patch | 287 ------------------------------------------------------ 216.patch | 38 ++++++++ php-pecl-zmq.spec | 35 +++---- 4 files changed, 53 insertions(+), 338 deletions(-) delete mode 100644 170.patch delete mode 100644 195.patch create mode 100644 216.patch diff --git a/170.patch b/170.patch deleted file mode 100644 index 45cde0b..0000000 --- a/170.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 7c961507e24435680e445b90af0a465c98246d4d Mon Sep 17 00:00:00 2001 -From: Remi Collet -Date: Mon, 1 Feb 2016 08:09:46 +0100 -Subject: [PATCH] Fix build with old GCC - ---- - zmq_pollset.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/zmq_pollset.c b/zmq_pollset.c -index 16dbdec..59f8c09 100644 ---- a/zmq_pollset.c -+++ b/zmq_pollset.c -@@ -38,7 +38,7 @@ - - /* {{{ typedef struct _php_zmq_pollset - */ --typedef struct _php_zmq_pollset { -+struct _php_zmq_pollset { - - zmq_pollitem_t *items; - zend_string **keys; -@@ -49,7 +49,7 @@ typedef struct _php_zmq_pollset { - size_t alloc_size; - - zval errors; --} php_zmq_pollset; -+}; - /* }}} */ - - static diff --git a/195.patch b/195.patch deleted file mode 100644 index 52881ea..0000000 --- a/195.patch +++ /dev/null @@ -1,287 +0,0 @@ -From af02bde61c2a5af1ae64cac09ffe2b25237aa58e Mon Sep 17 00:00:00 2001 -From: Alex/AT -Date: Mon, 10 Dec 2018 06:02:27 +0300 -Subject: [PATCH 1/2] PHP 7.3 compatibility and bugfixes - -- Define new GC_ADDREF/DELREF/SET_REFCOUNT macros for older PHP versions and use them instead of direct GC reference counter access - -- Fixup all necessary 'long' type parameters to 'zend_long', PHP 7.3 makes it mandatory, also fixup some direct function implementations to accept the same - -- In php_zmq_recv(), zend_string_init() was wrongly called with third parameter as '1', marking new string with IS_STR_PERSISTENT, this caused heap corruption and/or segfaults with PHP 7.3 and could possibly cause other sorts of bugs under any 7.x version - With ZVAL_STRINGL macro, this last '1' parameter meant to copy the string and was seemingly erroneously moved to zend_string_init(). zend_string_init() copies string by default, and last parameter has totally different meaning here - -- In poll(), flag ZVAL separation on passed arrays (PHP 7.3 makes it mandatory) - -- Test 19 (exception on connect callback with forced reference parameter): skip on PHP 7.1 and higher, PHP >= 7.1 started to fallback to passing argument by value instead of failing - -- Test 21 (warning generation from callback): it is ok, but PHP 7.3 uses 'int' instead of 'integer' for constants, so allow any word in place of the word 'integer' ---- - php_zmq.h | 6 ++++ - tests/019-callbackinvalidsignature.phpt | 3 +- - tests/021-callbackwarning.phpt | 2 +- - zmq.c | 40 ++++++++++++------------- - zmq_sockopt.c | 4 +-- - 5 files changed, 30 insertions(+), 25 deletions(-) - -diff --git a/php_zmq.h b/php_zmq.h -index ef50bfb..3833967 100644 ---- a/php_zmq.h -+++ b/php_zmq.h -@@ -44,6 +44,12 @@ - - #include "php.h" - -+#if PHP_VERSION_ID < 70300 -+#define GC_ADDREF(p) ++GC_REFCOUNT(p) -+#define GC_DELREF(p) --GC_REFCOUNT(p) -+#define GC_SET_REFCOUNT(p, rc) GC_REFCOUNT(p) = rc -+#endif -+ - extern zend_module_entry zmq_module_entry; - #define phpext_zmq_ptr &zmq_module_entry - -diff --git a/tests/019-callbackinvalidsignature.phpt b/tests/019-callbackinvalidsignature.phpt -index 753de31..b5bb20c 100644 ---- a/tests/019-callbackinvalidsignature.phpt -+++ b/tests/019-callbackinvalidsignature.phpt -@@ -1,7 +1,8 @@ - --TEST-- - Test callback edge-cases - --SKIPIF-- -- -+= 70100) die("skip PHP 7.1 and higher fallback to passing argument by value even when forced to reference"); ?> - --FILE-- - val, plist_key->len, &le, sizeof(le)) == NULL) { -@@ -369,7 +369,7 @@ PHP_METHOD(zmq, curvekeypair) - PHP_METHOD(zmqcontext, __construct) - { - php_zmq_context_object *intern; -- long io_threads = 1; -+ zend_long io_threads = 1; - zend_bool is_persistent = 1; - - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|lb", &io_threads, &is_persistent) == FAILURE) { -@@ -495,7 +495,7 @@ PHP_METHOD(zmqcontext, getOpt) - Create a new zmq socket - */ - static --php_zmq_socket *php_zmq_socket_new(php_zmq_context *context, int type, zend_bool is_persistent) -+php_zmq_socket *php_zmq_socket_new(php_zmq_context *context, zend_long type, zend_bool is_persistent) - { - php_zmq_socket *zmq_sock; - -@@ -503,7 +503,7 @@ php_zmq_socket *php_zmq_socket_new(php_zmq_context *context, int type, zend_bool - zmq_sock->z_socket = zmq_socket(context->z_ctx, type); - zmq_sock->pid = getpid(); - zmq_sock->ctx = context; -- zmq_sock->socket_type = type; -+ zmq_sock->socket_type = type; - - if (!zmq_sock->z_socket) { - pefree(zmq_sock, is_persistent); -@@ -535,7 +535,7 @@ void php_zmq_socket_store(php_zmq_socket *zmq_sock_p, zend_long type, zend_strin - le.type = php_zmq_socket_list_entry(); - le.ptr = zmq_sock_p; - -- GC_REFCOUNT(&le) = 1; -+ GC_SET_REFCOUNT(&le, 1); - - plist_key = php_zmq_socket_plist_key(type, persistent_id, use_shared_ctx); - -@@ -796,7 +796,7 @@ PHP_METHOD(zmqsocket, __construct) - - /* {{{ static zend_bool php_zmq_send(php_zmq_socket_object *intern, char *message_param, long flags) - */ --static zend_bool php_zmq_send(php_zmq_socket_object *intern, zend_string *message_param, long flags) -+static zend_bool php_zmq_send(php_zmq_socket_object *intern, zend_string *message_param, zend_long flags) - { - int rc, errno_; - zmq_msg_t message; -@@ -828,7 +828,7 @@ static void php_zmq_sendmsg_impl(INTERNAL_FUNCTION_PARAMETERS) - { - php_zmq_socket_object *intern; - zend_string *message_param; -- long flags = 0; -+ zend_long flags = 0; - zend_bool ret; - - if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|l", &message_param, &flags) == FAILURE) { -@@ -890,7 +890,7 @@ PHP_METHOD(zmqsocket, sendmulti) - zval *messages; - php_zmq_socket_object *intern; - int to_send, ret = 0; -- long flags = 0; -+ zend_long flags = 0; - - if (zend_parse_parameters(ZEND_NUM_ARGS(), "a|l", &messages, &flags) == FAILURE) { - return; -@@ -910,7 +910,7 @@ PHP_METHOD(zmqsocket, sendmulti) - /* {{{ static zend_bool php_zmq_recv(php_zmq_socket_object *intern, long flags, zval *return_value) - */ - static --zend_string *php_zmq_recv(php_zmq_socket_object *intern, long flags) -+zend_string *php_zmq_recv(php_zmq_socket_object *intern, zend_long flags) - { - int rc, errno_; - zmq_msg_t message; -@@ -933,7 +933,7 @@ zend_string *php_zmq_recv(php_zmq_socket_object *intern, long flags) - return NULL; - } - -- str = zend_string_init(zmq_msg_data(&message), zmq_msg_size(&message), 1); -+ str = zend_string_init(zmq_msg_data(&message), zmq_msg_size(&message), 0); - zmq_msg_close(&message); - return str; - } -@@ -943,7 +943,7 @@ static void php_zmq_recvmsg_impl(INTERNAL_FUNCTION_PARAMETERS) - { - zend_string *str = NULL; - php_zmq_socket_object *intern; -- long flags = 0; -+ zend_long flags = 0; - - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &flags) == FAILURE) { - return; -@@ -974,7 +974,7 @@ PHP_METHOD(zmqsocket, recvmulti) - { - php_zmq_socket_object *intern; - size_t value_len; -- long flags = 0; -+ zend_long flags = 0; - #if ZMQ_VERSION_MAJOR < 3 - int64_t value; - #else -@@ -1303,7 +1303,7 @@ PHP_METHOD(zmqpoll, add) - { - php_zmq_poll_object *intern; - zval *object; -- long events; -+ zend_long events; - int error; - zend_string *key; - -@@ -1423,10 +1423,10 @@ PHP_METHOD(zmqpoll, poll) - php_zmq_poll_object *intern; - zval *r_array, *w_array; - -- long timeout = -1; -+ zend_long timeout = -1; - int rc; - -- if (zend_parse_parameters(ZEND_NUM_ARGS(), "a!a!|l", &r_array, &w_array, &timeout) == FAILURE) { -+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "a!/a!/|l", &r_array, &w_array, &timeout) == FAILURE) { - return; - } - -@@ -1592,7 +1592,7 @@ void s_clear_device_callback (php_zmq_device_cb_t *cb) - } - - static --void s_init_device_callback (php_zmq_device_cb_t *cb, zend_fcall_info *fci, zend_fcall_info_cache *fci_cache, long timeout, zval *user_data) -+void s_init_device_callback (php_zmq_device_cb_t *cb, zend_fcall_info *fci, zend_fcall_info_cache *fci_cache, zend_long timeout, zval *user_data) - { - memcpy (&cb->fci, fci, sizeof (zend_fcall_info)); - memcpy (&cb->fci_cache, fci_cache, sizeof (zend_fcall_info_cache)); -@@ -1615,7 +1615,7 @@ void s_init_device_callback (php_zmq_device_cb_t *cb, zend_fcall_info *fci, zend - PHP_METHOD(zmqdevice, setidletimeout) - { - php_zmq_device_object *intern; -- long timeout; -+ zend_long timeout; - - if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &timeout) == FAILURE) { - return; -@@ -1644,7 +1644,7 @@ PHP_METHOD(zmqdevice, getidletimeout) - PHP_METHOD(zmqdevice, settimertimeout) - { - php_zmq_device_object *intern; -- long timeout; -+ zend_long timeout; - - if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &timeout) == FAILURE) { - return; -@@ -1676,7 +1676,7 @@ PHP_METHOD(zmqdevice, setidlecallback) - zval *user_data = NULL; - zend_fcall_info fci; - zend_fcall_info_cache fci_cache; -- long timeout = 0; -+ zend_long timeout = 0; - - if (ZEND_NUM_ARGS() == 2) { - php_error_docref(NULL, E_DEPRECATED, "The signature for setIdleCallback has changed, please update your code"); -@@ -1718,7 +1718,7 @@ PHP_METHOD(zmqdevice, settimercallback) - zval *user_data = NULL; - zend_fcall_info fci; - zend_fcall_info_cache fci_cache; -- long timeout; -+ zend_long timeout; - - if (zend_parse_parameters(ZEND_NUM_ARGS(), "fl|z!", &fci, &fci_cache, &timeout, &user_data) == FAILURE) { - return; -diff --git a/zmq_sockopt.c b/zmq_sockopt.c -index 1357032..3a00421 100644 ---- a/zmq_sockopt.c -+++ b/zmq_sockopt.c -@@ -1,5 +1,3 @@ -- -- - /* - +-----------------------------------------------------------------------------------+ - | ZMQ extension for PHP | -@@ -2033,7 +2031,7 @@ PHP_METHOD(zmqsocket, getsockopt) - PHP_METHOD(zmqsocket, setsockopt) - { - php_zmq_socket_object *intern; -- long key; -+ zend_long key; - zval *zv; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lz/", &key, &zv) == FAILURE) { - -From 55a19a84c36df4a2b75bc0acba19c0a9d9da3bd0 Mon Sep 17 00:00:00 2001 -From: Alex/AT -Date: Tue, 11 Dec 2018 15:11:44 +0300 -Subject: [PATCH 2/2] Update README.md - ---- - README.md | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/README.md b/README.md -index a798b54..6c0cd56 100644 ---- a/README.md -+++ b/README.md -@@ -1,7 +1,5 @@ - PHP bindings for 0MQ. The documentation is available at http://php.net/zmq - --[![Build Status](https://travis-ci.org/mkoppanen/php-zmq.png?branch=master)](https://travis-ci.org/mkoppanen/php-zmq) -- - The API is roughly as follows: - - +Date: Mon, 24 Aug 2020 15:55:54 +0200 +Subject: [PATCH] fix for PHP 8.0.0beta2 + +--- + zmq.c | 2 ++ + zmq_device.c | 2 ++ + 2 files changed, 4 insertions(+) + +diff --git a/zmq.c b/zmq.c +index 89902f9..bd2401d 100644 +--- a/zmq.c ++++ b/zmq.c +@@ -621,7 +621,9 @@ zend_bool php_zmq_connect_callback(zval *socket, zend_fcall_info *fci, zend_fcal + fci->params = params; + fci->param_count = 2; + fci->retval = &retval; ++#if PHP_VERSION_ID < 80000 + fci->no_separation = 1; ++#endif + + if (zend_call_function(fci, fci_cache) == FAILURE) { + if (!EG(exception)) { +diff --git a/zmq_device.c b/zmq_device.c +index 534f966..1c6aa3e 100644 +--- a/zmq_device.c ++++ b/zmq_device.c +@@ -53,7 +53,9 @@ zend_bool s_invoke_device_cb (php_zmq_device_cb_t *cb, uint64_t current_ts) + cb->fci.param_count = 1; + + /* Call the cb */ ++#if PHP_VERSION_ID < 80000 + cb->fci.no_separation = 1; ++#endif + cb->fci.retval = &fc_retval; + + if (zend_call_function(&(cb->fci), &(cb->fci_cache)) == FAILURE) { diff --git a/php-pecl-zmq.spec b/php-pecl-zmq.spec index c428179..2b7c92c 100644 --- a/php-pecl-zmq.spec +++ b/php-pecl-zmq.spec @@ -26,11 +26,13 @@ Summary: ZeroMQ messaging Name: %{?sub_prefix}php-pecl-%{pecl_name} Version: 1.1.3 -Release: 11%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} +Release: 12%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} License: BSD URL: https://pecl.php.net/package/%{pecl_name} Source0: https://pecl.php.net/get/%{pecl_name}-%{version}.tgz +Patch0: https://patch-diff.githubusercontent.com/raw/zeromq/php-zmq/pull/216.patch + BuildRequires: %{?dtsprefix}gcc BuildRequires: %{?scl_prefix}php-devel BuildRequires: %{?scl_prefix}php-pear @@ -49,9 +51,9 @@ Requires: %{?scl_prefix}php(api) = %{php_core_api} # Version 1.0.7 is the first pecl release # Fedora/EPEL still provides php-zmq, not php-pecl-zmq -Obsoletes: %{?scl_prefix}php-%{pecl_name} < %{version} -Provides: %{?scl_prefix}php-%{pecl_name} = %{version} -Provides: %{?scl_prefix}php-%{pecl_name}%{?_isa} = %{version} +Obsoletes: %{?scl_prefix}php-%{pecl_name} < %{version}-99 +Provides: %{?scl_prefix}php-%{pecl_name} = %{version}-99 +Provides: %{?scl_prefix}php-%{pecl_name}%{?_isa} = %{version}-99 Provides: %{?scl_prefix}php-pecl(%{pecl_name}) = %{version} Provides: %{?scl_prefix}php-pecl(%{pecl_name})%{?_isa} = %{version} %if "%{?scl_prefix}" != "%{?sub_prefix}" @@ -59,31 +61,19 @@ Provides: %{?scl_prefix}php-pecl-%{pecl_name} = %{version}-%{rele Provides: %{?scl_prefix}php-pecl-%{pecl_name}%{?_isa} = %{version}-%{release} %endif -%if "%{?vendor}" == "Remi Collet" && 0%{!?scl:1} && 0%{?rhel} +%if "%{?packager}" == "Remi Collet" && 0%{!?scl:1} && 0%{?rhel} # Other third party repo stuff -%if "%{php_version}" > "5.6" -Obsoletes: php56u-pecl-%{pecl_name} <= %{version} -Obsoletes: php56w-pecl-%{pecl_name} <= %{version} -%endif -%if "%{php_version}" > "7.0" -Obsoletes: php70u-pecl-%{pecl_name} <= %{version} -Obsoletes: php70w-pecl-%{pecl_name} <= %{version} -%endif -%if "%{php_version}" > "7.1" -Obsoletes: php71u-pecl-%{pecl_name} <= %{version} -Obsoletes: php71w-pecl-%{pecl_name} <= %{version} -%endif %if "%{php_version}" > "7.2" Obsoletes: php72u-pecl-%{pecl_name} <= %{version} -Obsoletes: php72w-pecl-%{pecl_name} <= %{version} %endif %if "%{php_version}" > "7.3" Obsoletes: php73-pecl-%{pecl_name} <= %{version} -Obsoletes: php73w-pecl-%{pecl_name} <= %{version} %endif %if "%{php_version}" > "7.4" Obsoletes: php74-pecl-%{pecl_name} <= %{version} -Obsoletes: php74w-pecl-%{pecl_name} <= %{version} +%endif +%if "%{php_version}" > "8.0" +Obsoletes: php80-pecl-%{pecl_name} <= %{version} %endif %endif @@ -112,6 +102,8 @@ sed -e 's/role="test"/role="src"/' \ mv %{pecl_name}-%{version} NTS cd NTS +%patch0 -p1 -b .pr216 + if pkg-config libzmq --atleast-version=4 then # fix new default of MAX_SOCKETS @@ -254,6 +246,9 @@ export TEST_PHP_EXECUTABLE=%{__ztsphp} %changelog +* Mon Aug 24 2020 Remi Collet - 1.1.3-12 +- add patch for PHP 8 from https://github.com/zeromq/php-zmq/pull/216 + * Wed Nov 27 2019 Remi Collet - 1.1.3-11 - EL-8 rebuild -- cgit