From 8201344d7fcb634713b76d4cae38f6f38a923afb Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 27 Sep 2021 16:23:13 +0200 Subject: more upstream patches --- .gitignore | 2 + REFLECTION | 2 +- php-pecl-stomp.spec | 42 +- stomp-php8.patch | 1639 ----------------------------------------------- stomp-upstream.patch | 1743 ++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 1779 insertions(+), 1649 deletions(-) delete mode 100644 stomp-php8.patch create mode 100644 stomp-upstream.patch diff --git a/.gitignore b/.gitignore index 1ab5c4f..01f0400 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ +clog package-*.xml *.tgz +*.tar.bz2 *.tar.gz *.tar.xz *.tar.xz.asc diff --git a/REFLECTION b/REFLECTION index 6251362..3515194 100644 --- a/REFLECTION +++ b/REFLECTION @@ -1,4 +1,4 @@ -Extension [ extension #146 Stomp version 2.0.2 ] { +Extension [ extension #124 Stomp version 2.0.2 ] { - INI { Entry [ stomp.default_broker ] diff --git a/php-pecl-stomp.spec b/php-pecl-stomp.spec index 5f16bb2..0584a75 100644 --- a/php-pecl-stomp.spec +++ b/php-pecl-stomp.spec @@ -9,6 +9,9 @@ %{?scl: %scl_package php-pecl-stomp} %{!?scl: %global _root_prefix %{_prefix}} +# to run full test suite using a rabbitmq server +%bcond_with tests + %global with_zts 0%{!?_without_zts:%{?__ztsphp:1}} %global pecl_name stomp %global ini_name 40-%{pecl_name}.ini @@ -16,18 +19,21 @@ Summary: Stomp client extension Name: %{?scl_prefix}php-pecl-%{pecl_name} Version: 2.0.2 -Release: 6%{?dist}%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')} +Release: 7%{?dist}%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')} License: PHP URL: https://pecl.php.net/package/%{pecl_name} Source0: https://pecl.php.net/get/%{pecl_name}-%{version}.tgz -Patch0: %{pecl_name}-php8.patch +Patch0: %{pecl_name}-upstream.patch BuildRequires: %{?dtsprefix}gcc BuildRequires: make BuildRequires: %{?scl_prefix}php-devel > 7 BuildRequires: %{?scl_prefix}php-pear BuildRequires: openssl-devel +%if %{with tests} +BuildRequires: rabbitmq-server +%endif Requires: %{?scl_prefix}php(zend-abi) = %{php_zend_api} Requires: %{?scl_prefix}php(api) = %{php_core_api} @@ -79,7 +85,7 @@ sed -e 's/role="test"/role="src"/' \ -i package.xml cd NTS -%patch0 -p1 -b .pr14 +%patch0 -p1 -b .upstream # Sanity check, really often broken extver=$(sed -n '/#define PHP_STOMP_VERSION/{s/.* "//;s/".*$//;p}' php_stomp.h) @@ -117,11 +123,7 @@ EOF peclbuild() { %configure \ --enable-stomp \ -%if "%{php_version}" > "7.4" - --with-openssl \ -%else --with-openssl-dir=%{_root_prefix} \ -%endif --with-libdir=%{_lib} \ --with-php-config=$1 @@ -198,11 +200,30 @@ fi %endif cd NTS -# need a server, such as rabbitmq-server +%if %{with tests} +mkdir log run base +: Launch the RabbitMQ service +export RABBITMQ_PID_FILE=$PWD/run/pid +export RABBITMQ_LOG_BASE=$PWD/log +export RABBITMQ_MNESIA_BASE=$PWD/base +/usr/lib/rabbitmq/bin/rabbitmq-server &>log/output & +/usr/lib/rabbitmq/bin/rabbitmqctl wait $RABBITMQ_PID_FILE +%endif + : Run upstream test suite +ret=0 TEST_PHP_EXECUTABLE=%{__php} \ TEST_PHP_ARGS="-n -d extension=%{buildroot}%{php_extdir}/%{pecl_name}.so" \ -%{__php} -n run-tests.php -q --show-diff +%{__php} -n run-tests.php -q --show-diff || ret=1 + +%if %{with tests} +if [ -s $RABBITMQ_PID_FILE ]; then + kill $(cat $RABBITMQ_PID_FILE) +fi +rm -rf log run base +%endif + +exit $ret %files @@ -220,6 +241,9 @@ TEST_PHP_ARGS="-n -d extension=%{buildroot}%{php_extdir}/%{pecl_name}.so" \ %changelog +* Mon Sep 27 2021 Remi Collet - 2.0.2-7 +- more upstream patches + * Mon Sep 27 2021 Remi Collet - 2.0.2-6 - add patch for PHP 8 from https://github.com/php/pecl-tools-stomp/pull/14 diff --git a/stomp-php8.patch b/stomp-php8.patch deleted file mode 100644 index 46b1f09..0000000 --- a/stomp-php8.patch +++ /dev/null @@ -1,1639 +0,0 @@ -From 7b066620afe3368662e316e86242d0087de8a44e Mon Sep 17 00:00:00 2001 -From: Peter Kokot -Date: Sat, 30 Jun 2018 16:44:34 +0200 -Subject: [PATCH] Remove unused Git attributes ident - -The $Id$ keywords were used in Subversion where they can be substituted -with filename, last revision number change, last changed date, and last -user who changed it. - -In Git this functionality is different and can be done with Git attribute -ident. These need to be defined manually for each file in the -.gitattributes file and are afterwards replaced with 40-character -hexadecimal blob object name which is based only on the particular file -contents. - -This patch simplifes handling of $Id$ keywords by removing them since -they are not used anymore. ---- - config.m4 | 1 - - config.w32 | 1 - - php_stomp.c | 2 -- - php_stomp.h | 2 -- - stomp.c | 2 -- - stomp.h | 2 -- - 6 files changed, 10 deletions(-) - -diff --git a/config.m4 b/config.m4 -index 8a9c36b..f700f27 100644 ---- a/config.m4 -+++ b/config.m4 -@@ -1,4 +1,3 @@ --dnl $Id$ - dnl config.m4 for extension stomp - - PHP_ARG_ENABLE(stomp, whether to enable stomp support, -diff --git a/config.w32 b/config.w32 -index 091e00b..ba3096b 100644 ---- a/config.w32 -+++ b/config.w32 -@@ -1,4 +1,3 @@ --// $Id$ - // vim:ft=javascript - - ARG_ENABLE("stomp", "enable stomp support", "no"); -diff --git a/php_stomp.c b/php_stomp.c -index 9442011..080298f 100644 ---- a/php_stomp.c -+++ b/php_stomp.c -@@ -16,8 +16,6 @@ - +----------------------------------------------------------------------+ - */ - --/* $Id$ */ -- - #ifdef HAVE_CONFIG_H - #include "config.h" - #endif -diff --git a/php_stomp.h b/php_stomp.h -index b799119..805b9f6 100644 ---- a/php_stomp.h -+++ b/php_stomp.h -@@ -16,8 +16,6 @@ - +----------------------------------------------------------------------+ - */ - --/* $Id$ */ -- - #ifndef PHP_STOMP_H - #define PHP_STOMP_H - -diff --git a/stomp.c b/stomp.c -index 2f71606..d83a4e6 100644 ---- a/stomp.c -+++ b/stomp.c -@@ -16,8 +16,6 @@ - +----------------------------------------------------------------------+ - */ - --/* $Id$ */ -- - #ifdef HAVE_CONFIG_H - #include "config.h" - #endif -diff --git a/stomp.h b/stomp.h -index a47787f..19bd8dd 100644 ---- a/stomp.h -+++ b/stomp.h -@@ -16,8 +16,6 @@ - +----------------------------------------------------------------------+ - */ - --/* $Id$ */ -- - #ifndef _STOMP_H_ - #define _STOMP_H_ - - -From 684706756972bb75fec025ec9d66c3fc99ed5199 Mon Sep 17 00:00:00 2001 -From: Peter Kokot -Date: Wed, 3 Oct 2018 09:43:57 +0200 -Subject: [PATCH] Trim trailing whitespace - ---- - LICENSE | 26 ++++----- - README | 2 +- - TODO | 2 +- - config.m4 | 2 +- - doc/classes.php | 48 ++++++++-------- - doc/functions.php | 44 +++++++-------- - php_stomp.c | 94 ++++++++++++++++---------------- - php_stomp.h | 4 +- - stomp.h | 4 +- - tests/002-version.phpt | 2 +- - tests/003-connect/001.phpt | 2 +- - tests/003-connect/002.phpt | 4 +- - tests/003-connect/003.phpt | 2 +- - tests/004-getSessionId/001.phpt | 4 +- - tests/005-close/001.phpt | 4 +- - tests/005-close/002.phpt | 4 +- - tests/006-send/001.phpt | 2 +- - tests/006-send/002.phpt | 2 +- - tests/006-send/003.phpt | 2 +- - tests/007-subscribe/001.phpt | 2 +- - tests/008-unsubscribe/001.phpt | 2 +- - tests/009-readFrame/001.phpt | 2 +- - tests/009-readFrame/003.phpt | 4 +- - tests/009-readFrame/004.phpt | Bin 433 -> 432 bytes - tests/009-readFrame/006.phpt | 2 +- - tests/010-timeout/001.phpt | 4 +- - tests/010-timeout/002.phpt | 4 +- - tests/011-commit/001.phpt | 2 +- - tests/skipif.inc | 2 +- - 29 files changed, 139 insertions(+), 139 deletions(-) - -diff --git a/LICENSE b/LICENSE -index 6059c80..92ee907 100644 ---- a/LICENSE -+++ b/LICENSE -@@ -1,7 +1,7 @@ ---------------------------------------------------------------------- -+-------------------------------------------------------------------- - The PHP License, version 3.01 - Copyright (c) 1999 - 2014 The PHP Group. All rights reserved. ---------------------------------------------------------------------- -+-------------------------------------------------------------------- - - Redistribution and use in source and binary forms, with or without - modification, is permitted provided that the following conditions -@@ -9,22 +9,22 @@ are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -- -+ - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. -- -+ - 3. The name "PHP" must not be used to endorse or promote products - derived from this software without prior written permission. For - written permission, please contact group@php.net. -- -+ - 4. Products derived from this software may not be called "PHP", nor - may "PHP" appear in their name, without prior written permission - from group@php.net. You may indicate that your software works in - conjunction with PHP by saying "Foo for PHP" instead of calling - it "PHP Foo" or "phpfoo" -- -+ - 5. The PHP Group may publish revised and/or new versions of the - license from time to time. Each version will be given a - distinguishing version number. -@@ -41,27 +41,27 @@ are met: - "This product includes PHP software, freely available from - ". - --THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND -+THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND - ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, --THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP --DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, --INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES --(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -+DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. - ---------------------------------------------------------------------- -+-------------------------------------------------------------------- - - This software consists of voluntary contributions made by many - individuals on behalf of the PHP Group. - - The PHP Group can be contacted via Email at group@php.net. - --For more information on the PHP Group and the PHP project, -+For more information on the PHP Group and the PHP project, - please see . - - PHP includes the Zend Engine, freely available at -diff --git a/README b/README -index 6511d8b..a0c1953 100644 ---- a/README -+++ b/README -@@ -1,7 +1,7 @@ - stomp - ===== - --This extension allows php applications to communicate with any Stomp compliant Message Broker(s) through easy object -+This extension allows php applications to communicate with any Stomp compliant Message Broker(s) through easy object - oriented and procedural interfaces. - - This extension currently implements STOMP 1.0 protocol: https://stomp.github.io/stomp-specification-1.0.html -diff --git a/config.m4 b/config.m4 -index f700f27..cbeb71b 100644 ---- a/config.m4 -+++ b/config.m4 -@@ -16,7 +16,7 @@ if test "$PHP_STOMP" != "no"; then - [ - AC_DEFINE(HAVE_STOMP_SSL,1,[ ]) - ], [ -- AC_MSG_ERROR([OpenSSL libraries not found. -+ AC_MSG_ERROR([OpenSSL libraries not found. - - Check the path given to --with-openssl-dir and output in config.log) - ]) -diff --git a/doc/classes.php b/doc/classes.php -index 0cfc554..06c50a0 100644 ---- a/doc/classes.php -+++ b/doc/classes.php -@@ -4,7 +4,7 @@ class Stomp { - - /** - * Connect to server -- * -+ * - * @param string $broker The broker URI - * @param string $username The username - * @param string $password The password -@@ -15,7 +15,7 @@ public function __construct($broker = null, $username = null, $password = null, - - /** - * Get the current stomp session ID -- * -+ * - * @return string stomp session ID if it exists, or FALSE otherwise - */ - public function getSessionId() { -@@ -24,28 +24,28 @@ public function getSessionId() { - /** - * Close stomp connection - * -- * @return boolean TRUE on success, or FALSE on failure -+ * @return boolean TRUE on success, or FALSE on failure - */ - public function disconnect() { - } - -- /** -+ /** - * Sends a message to a destination in the messaging system -- * -- * @param string $destination indicates where to send the message -+ * -+ * @param string $destination indicates where to send the message - * @param string|StompFrame $msg message to be sent - * @param array $headers additional headers (example: receipt). -- * @return boolean TRUE on success, or FALSE on failure -+ * @return boolean TRUE on success, or FALSE on failure - */ - public function send($destination, $msg, array $headers = array()) { - } - - /** - * Register to listen to a given destination -- * -- * @param string $destination indicates which destination to subscribe to -+ * -+ * @param string $destination indicates which destination to subscribe to - * @param array $headers additional headers (example: receipt). -- * @return boolean TRUE on success, or FALSE on failure -+ * @return boolean TRUE on success, or FALSE on failure - */ - public function subscribe($destination, array $headers = array()) { - } -@@ -55,14 +55,14 @@ public function subscribe($destination, array $headers = array()) { - * - * @param string $destination indicates which subscription to remove - * @param array $headers additional headers (example: receipt). -- * @return boolean TRUE on success, or FALSE on failure -+ * @return boolean TRUE on success, or FALSE on failure - */ - public function unsubscribe($destination, array $headers = array()) { - } - - /** - * Indicate whether or not there is a frame ready to read -- * -+ * - * @return boolean TRUE if there is one, or FALSE otherwise - */ - public function hasFrame() { -@@ -81,7 +81,7 @@ public function readFrame($className = 'stompFrame') { - * Start a transaction - * - * @param string $transaction_id transaction id -- * @return boolean TRUE on success, or FALSE on failure -+ * @return boolean TRUE on success, or FALSE on failure - */ - public function begin($transaction_id) { - } -@@ -90,26 +90,26 @@ public function begin($transaction_id) { - * Commit a transaction in progress - * - * @param string $transaction_id transaction id -- * @return boolean TRUE on success, or FALSE on failure -+ * @return boolean TRUE on success, or FALSE on failure - */ -- public function commit($transaction_id) { -+ public function commit($transaction_id) { - } - - /** - * Roll back a transaction in progress - * - * @param string $transaction_id transaction id -- * @return boolean TRUE on success, or FALSE on failure -+ * @return boolean TRUE on success, or FALSE on failure - */ - public function abort($transaction_id) { - } - - /** - * Acknowledge consumption of a message from a subscription using client acknowledgment -- * -+ * - * @param string|StompFrame $msg message/messageId to be acknowledged - * @param array $headers additional headers (example: receipt). -- * @return boolean TRUE on success, or FALSE on failure -+ * @return boolean TRUE on success, or FALSE on failure - */ - public function ack($msg, array $headers = array()) { - } -@@ -124,7 +124,7 @@ public function error() { - - /** - * Set timeout -- * -+ * - * @param int $seconds the seconds part of the timeout to be set - * @param int $microseconds the microseconds part of the timeout to be set - * @return void -@@ -134,16 +134,16 @@ public function setTimeout($seconds, $microseconds = 0) { - - /** - * Get timeout -- * -+ * - * @return array Array with timeout informations - */ - public function getTimeout() { -- } -+ } - - } - - class StompFrame { -- -+ - /** - * Frame Command - * @var String -@@ -164,11 +164,11 @@ class StompFrame { - } - - class StompException extends Exception { -- -+ - /** - * Get the stomp server error details - * -- * @return string -+ * @return string - */ - public function getDetails() { - } -diff --git a/doc/functions.php b/doc/functions.php -index 98486fc..57ae424 100644 ---- a/doc/functions.php -+++ b/doc/functions.php -@@ -2,7 +2,7 @@ - - /** - * Get the current version of the stomp extension -- * -+ * - * @return string version - */ - function stomp_version() { -@@ -10,19 +10,19 @@ function stomp_version() { - - /** - * Connect to server -- * -+ * - * @param string $broker broker URI - * @param string $username The username - * @param string $password The password - * @param array $headers additional headers (example: receipt). -- * @return Ressource stomp connection identifier on success, or FALSE on failure -+ * @return Ressource stomp connection identifier on success, or FALSE on failure - */ - function stomp_connect($broker = null, $username = null, $password = null, array $headers = array()) { - } - - /** - * Get the current stomp session ID -- * -+ * - * @param ressource $link identifier returned by stomp_connect - * @return string stomp session ID if it exists, or FALSE otherwise - */ -@@ -33,30 +33,30 @@ function stomp_get_session_id($link) { - * Close stomp connection - * - * @param ressource $link identifier returned by stomp_connect -- * @return boolean TRUE on success, or FALSE on failure -+ * @return boolean TRUE on success, or FALSE on failure - */ - function stomp_close($link) { - } - --/** -+/** - * Sends a message to a destination in the messaging system -- * -+ * - * @param ressource $link identifier returned by stomp_connect -- * @param string $destination indicates where to send the message -+ * @param string $destination indicates where to send the message - * @param string|StompFrame $msg message to be sent - * @param array $headers additional headers (example: receipt). -- * @return boolean TRUE on success, or FALSE on failure -+ * @return boolean TRUE on success, or FALSE on failure - */ - function stomp_send($link, $destination, $msg, array $headers = array()) { - } - - /** - * Register to listen to a given destination -- * -+ * - * @param ressource $link identifier returned by stomp_connect -- * @param string $destination indicates which destination to subscribe to -+ * @param string $destination indicates which destination to subscribe to - * @param array $headers additional headers (example: receipt). -- * @return boolean TRUE on success, or FALSE on failure -+ * @return boolean TRUE on success, or FALSE on failure - */ - function stomp_subscribe($link, $destination, array $headers = array()) { - } -@@ -67,14 +67,14 @@ function stomp_subscribe($link, $destination, array $headers = array()) { - * @param ressource $link identifier returned by stomp_connect - * @param string $destination indicates which subscription to remove - * @param array $headers additional headers (example: receipt). -- * @return boolean TRUE on success, or FALSE on failure -+ * @return boolean TRUE on success, or FALSE on failure - */ - function stomp_unsubscribe($link, $destination, array $headers = array()) { - } - - /** - * Indicate whether or not there is a frame ready to read -- * -+ * - * @param ressource $link identifier returned by stomp_connect - * @return boolean TRUE if there is one, or FALSE otherwise - */ -@@ -95,7 +95,7 @@ function stomp_read_frame($link) { - * - * @param ressource $link identifier returned by stomp_connect - * @param string $transaction_id transaction id -- * @return boolean TRUE on success, or FALSE on failure -+ * @return boolean TRUE on success, or FALSE on failure - */ - function stomp_begin($link, $transaction_id) { - } -@@ -105,9 +105,9 @@ function stomp_begin($link, $transaction_id) { - * - * @param ressource $link identifier returned by stomp_connect - * @param string $transaction_id transaction id -- * @return boolean TRUE on success, or FALSE on failure -+ * @return boolean TRUE on success, or FALSE on failure - */ --function stomp_commit($link, $transaction_id) { -+function stomp_commit($link, $transaction_id) { - } - - /** -@@ -115,18 +115,18 @@ function stomp_commit($link, $transaction_id) { - * - * @param ressource $link identifier returned by stomp_connect - * @param string $transaction_id transaction id -- * @return boolean TRUE on success, or FALSE on failure -+ * @return boolean TRUE on success, or FALSE on failure - */ - function stomp_abort($link, $transaction_id) { - } - - /** - * Acknowledge consumption of a message from a subscription using client acknowledgment -- * -+ * - * @param ressource $link identifier returned by stomp_connect - * @param string|StompFrame $msg message/messageId to be acknowledged - * @param array $headers additional headers (example: receipt). -- * @return boolean TRUE on success, or FALSE on failure -+ * @return boolean TRUE on success, or FALSE on failure - */ - function stomp_ack($link, $msg, array $headers = array()) { - } -@@ -142,7 +142,7 @@ function stomp_error($link) { - - /** - * Set timeout -- * -+ * - * @param ressource $link identifier returned by stomp_connect - * @param int $seconds the seconds part of the timeout to be set - * @param int $microseconds the microseconds part of the timeout to be set -@@ -153,7 +153,7 @@ function stomp_set_timeout($link, $seconds, $microseconds = 0) { - - /** - * Get timeout -- * -+ * - * @param ressource $link identifier returned by stomp_connect - * @return array Array with timeout informations - */ -diff --git a/php_stomp.c b/php_stomp.c -index 080298f..0dcefed 100644 ---- a/php_stomp.c -+++ b/php_stomp.c -@@ -83,7 +83,7 @@ - STOMP_G(error_msg) = estrdup(msg); \ - if (stomp_object) { \ - zend_throw_exception_ex(stomp_ce_exception, errno , msg); \ -- } -+ } - - #define STOMP_ERROR_DETAILS(errno, msg, details) \ - STOMP_G(error_no) = errno; \ -@@ -157,7 +157,7 @@ ZEND_ARG_ARRAY_INFO(0, headers, 1) - ZEND_END_ARG_INFO() - - ZEND_BEGIN_ARG_INFO_EX(stomp_readframe_args, 0, 0, 1) --ZEND_ARG_INFO(0, link) -+ZEND_ARG_INFO(0, link) - ZEND_ARG_INFO(0, class_name) - ZEND_END_ARG_INFO() - -@@ -213,7 +213,7 @@ ZEND_BEGIN_ARG_INFO_EX(stomp_frame_construct_args, 0, 0, 0) - ZEND_ARG_INFO(0, command) - ZEND_ARG_ARRAY_INFO(0, headers, 1) - ZEND_ARG_INFO(0, body) --ZEND_END_ARG_INFO() -+ZEND_END_ARG_INFO() - /* }}} */ - - /* {{{ stomp_functions */ -@@ -267,7 +267,7 @@ static zend_function_entry stomp_frame_methods[] = { - PHP_ME(stompframe, __construct, stomp_frame_construct_args, ZEND_ACC_PUBLIC) - {NULL, NULL, NULL} - }; --/* }}} */ -+/* }}} */ - - /* {{{ stomp_exception_methods[] */ - static zend_function_entry stomp_exception_methods[] = { -@@ -283,7 +283,7 @@ zend_module_entry stomp_module_entry = { - stomp_functions, - PHP_MINIT(stomp), - PHP_MSHUTDOWN(stomp), -- PHP_RINIT(stomp), -+ PHP_RINIT(stomp), - PHP_RSHUTDOWN(stomp), - PHP_MINFO(stomp), - PHP_STOMP_VERSION, -@@ -330,9 +330,9 @@ ZEND_GET_MODULE(stomp) - /* {{{ constructor/destructor */ - static void stomp_send_disconnect(stomp_t *stomp) - { -- stomp_frame_t frame = {0}; -+ stomp_frame_t frame = {0}; - INIT_FRAME(frame, "DISCONNECT"); -- -+ - stomp_send(stomp, &frame ); - CLEAR_FRAME(frame); - } -@@ -342,7 +342,7 @@ static void php_destroy_stomp_res(zend_resource *rsrc) - stomp_t *stomp = (stomp_t *) rsrc->ptr; - stomp_send_disconnect(stomp ); - stomp_close(stomp); --} -+} - - static zend_object *php_stomp_new(zend_class_entry *ce) - { -@@ -350,7 +350,7 @@ static zend_object *php_stomp_new(zend_class_entry *ce) - - intern = (stomp_object_t *) ecalloc(1, sizeof(stomp_object_t) + zend_object_properties_size(ce)); - intern->stomp = NULL; -- -+ - zend_object_std_init(&intern->std, ce ); - - intern->std.handlers = &stomp_obj_handlers; -@@ -381,7 +381,7 @@ PHP_MINIT_FUNCTION(stomp) - /* Properties */ - zend_declare_property_null(stomp_ce_frame, "command", sizeof("command")-1, ZEND_ACC_PUBLIC ); - zend_declare_property_null(stomp_ce_frame, "headers", sizeof("headers")-1, ZEND_ACC_PUBLIC ); -- zend_declare_property_null(stomp_ce_frame, "body", sizeof("body")-1, ZEND_ACC_PUBLIC ); -+ zend_declare_property_null(stomp_ce_frame, "body", sizeof("body")-1, ZEND_ACC_PUBLIC ); - - /* Register StompException class */ - INIT_CLASS_ENTRY(ce, PHP_STOMP_EXCEPTION_CLASSNAME, stomp_exception_methods); -@@ -399,7 +399,7 @@ PHP_MINIT_FUNCTION(stomp) - - /* {{{ PHP_MSHUTDOWN_FUNCTION */ - PHP_MSHUTDOWN_FUNCTION(stomp) --{ -+{ - /* Unregister INI entries */ - UNREGISTER_INI_ENTRIES(); - return SUCCESS; -@@ -443,9 +443,9 @@ PHP_MINFO_FUNCTION(stomp) - } - /* }}} */ - --/* {{{ proto string stomp_version() -+/* {{{ proto string stomp_version() - Get stomp extension version */ --PHP_FUNCTION(stomp_version) -+PHP_FUNCTION(stomp_version) - { - RETURN_STRINGL(PHP_STOMP_VERSION, sizeof(PHP_STOMP_VERSION)-1); - } -@@ -461,9 +461,9 @@ PHP_FUNCTION(stomp_connect) - zend_string *broker = NULL, *username = NULL, *password = NULL; - php_url *url_parts; - --#ifdef HAVE_STOMP_SSL -+#ifdef HAVE_STOMP_SSL - int use_ssl = 0; --#endif -+#endif - - if (zend_parse_parameters(ZEND_NUM_ARGS() , "|SSSa!", &broker, &username, &password, &headers) == FAILURE) { - return; -@@ -478,7 +478,7 @@ PHP_FUNCTION(stomp_connect) - } - - url_parts = php_url_parse_ex(ZSTR_VAL(broker), ZSTR_LEN(broker)); -- -+ - if (!url_parts || !url_parts->host) { - STOMP_ERROR(0, PHP_STOMP_ERR_INVALID_BROKER_URI); - zend_string_release(broker); -@@ -495,7 +495,7 @@ PHP_FUNCTION(stomp_connect) - STOMP_ERROR(0, "SSL DISABLED"); - php_url_free(url_parts); - return; --#endif -+#endif - } else if (strcmp(STOMP_URL_STR(url_parts->scheme), "tcp") != 0) { - STOMP_ERROR(0, PHP_STOMP_ERR_INVALID_BROKER_URI_SCHEME); - php_url_free(url_parts); -@@ -507,7 +507,7 @@ PHP_FUNCTION(stomp_connect) - - #if HAVE_STOMP_SSL - stomp->options.use_ssl = use_ssl; --#endif -+#endif - - stomp->options.read_timeout_sec = STOMP_G(read_timeout_sec); - stomp->options.read_timeout_usec = STOMP_G(read_timeout_usec); -@@ -522,7 +522,7 @@ PHP_FUNCTION(stomp_connect) - stomp_frame_t *res; - stomp_frame_t frame = {0}; - int send_status; -- -+ - INIT_FRAME(frame, "CONNECT"); - if (!username) { - username = zend_string_init(STOMP_G(default_username), strlen(STOMP_G(default_username)), 0); -@@ -548,7 +548,7 @@ PHP_FUNCTION(stomp_connect) - ZVAL_STR(&rv, zend_string_copy(password)); - zend_hash_str_add(frame.headers, "passcode", sizeof("passcode"), &rv); - } -- -+ - zend_string_release(username); - zend_string_release(password); - -@@ -607,7 +607,7 @@ PHP_FUNCTION(stomp_connect) - i_obj->stomp = stomp; - RETURN_TRUE; - } -- } -+ } - } else { - STOMP_ERROR_DETAILS(0, stomp->error, stomp->error_details); - } -@@ -617,9 +617,9 @@ PHP_FUNCTION(stomp_connect) - } - /* }}} */ - --/* {{{ proto string stomp_connect_error() -+/* {{{ proto string stomp_connect_error() - Get the last connection error */ --PHP_FUNCTION(stomp_connect_error) -+PHP_FUNCTION(stomp_connect_error) - { - if (STOMP_G(error_msg)) { - RETURN_STRING(STOMP_G(error_msg)); -@@ -629,7 +629,7 @@ PHP_FUNCTION(stomp_connect_error) - } - /* }}} */ - --/* {{{ proto string Stomp::getSessionId() -+/* {{{ proto string Stomp::getSessionId() - Get the current stomp session ID */ - PHP_FUNCTION(stomp_get_session_id) - { -@@ -695,13 +695,13 @@ PHP_FUNCTION(stomp_send) - stomp_t *stomp = NULL; - zend_string *destination; - zval *msg, *headers = NULL, rv; -- stomp_frame_t frame = {0}; -+ stomp_frame_t frame = {0}; - int success = 0; - - if (stomp_object) { - if (zend_parse_parameters(ZEND_NUM_ARGS() , "Sz|a!", &destination, &msg, &headers) == FAILURE) { - return; -- } -+ } - FETCH_STOMP_OBJECT; - } else { - zval *arg; -@@ -718,7 +718,7 @@ PHP_FUNCTION(stomp_send) - } - - INIT_FRAME(frame, "SEND"); -- -+ - /* Translate a PHP array to a stomp_header array */ - if (NULL != headers) { - FRAME_HEADER_FROM_HASHTABLE(frame.headers, Z_ARRVAL_P(headers)); -@@ -727,7 +727,7 @@ PHP_FUNCTION(stomp_send) - /* Add the destination */ - ZVAL_STR(&rv, zend_string_copy(destination)); - zend_hash_str_add(frame.headers, "destination", sizeof("destination") - 1, &rv); -- -+ - if (Z_TYPE_P(msg) == IS_STRING) { - frame.body = Z_STRVAL_P(msg); - frame.body_length = Z_STRLEN_P(msg); -@@ -770,7 +770,7 @@ PHP_FUNCTION(stomp_subscribe) - stomp_t *stomp = NULL; - zend_string *destination; - zval *headers = NULL, rv; -- stomp_frame_t frame = {0}; -+ stomp_frame_t frame = {0}; - int success = 0; - - if (stomp_object) { -@@ -793,7 +793,7 @@ PHP_FUNCTION(stomp_subscribe) - } - - INIT_FRAME(frame, "SUBSCRIBE"); -- -+ - /* Translate a PHP array to a stomp_header array */ - if (NULL != headers) { - FRAME_HEADER_FROM_HASHTABLE(frame.headers, Z_ARRVAL_P(headers)); -@@ -824,7 +824,7 @@ PHP_FUNCTION(stomp_unsubscribe) - stomp_t *stomp = NULL; - zend_string *destination; - zval *headers = NULL, rv; -- stomp_frame_t frame = {0}; -+ stomp_frame_t frame = {0}; - int success = 0; - - if (stomp_object) { -@@ -847,7 +847,7 @@ PHP_FUNCTION(stomp_unsubscribe) - } - - INIT_FRAME(frame, "UNSUBSCRIBE"); -- -+ - /* Translate a PHP array to a stomp_header array */ - if (NULL != headers) { - FRAME_HEADER_FROM_HASHTABLE(frame.headers, Z_ARRVAL_P(headers)); -@@ -866,9 +866,9 @@ PHP_FUNCTION(stomp_unsubscribe) - } - /* }}} */ - --/* {{{ proto boolean Stomp::hasFrame() -+/* {{{ proto boolean Stomp::hasFrame() - Indicate whether or not there is a frame ready to read */ --PHP_FUNCTION(stomp_has_frame) -+PHP_FUNCTION(stomp_has_frame) - { - zval *stomp_object = getThis(); - stomp_t *stomp = NULL; -@@ -886,7 +886,7 @@ PHP_FUNCTION(stomp_has_frame) - } - /* }}} */ - --/* {{{ proto StompFrame Stomp::readFrame() -+/* {{{ proto StompFrame Stomp::readFrame() - Read the next frame */ - PHP_FUNCTION(stomp_read_frame) - { -@@ -947,7 +947,7 @@ PHP_FUNCTION(stomp_read_frame) - zend_hash_update(Z_ARRVAL(headers), key, val); - } ZEND_HASH_FOREACH_END(); - } -- -+ - if (ce) { - zend_fcall_info fci; - zend_fcall_info_cache fcc; -@@ -1029,14 +1029,14 @@ static void _php_stomp_transaction(INTERNAL_FUNCTION_PARAMETERS, char *cmd, size - zval *stomp_object = getThis(); - stomp_t *stomp = NULL; - zend_string *transaction_id; -- stomp_frame_t frame = {0}; -+ stomp_frame_t frame = {0}; - int success = 0; - zval *headers = NULL, rv; - - if (stomp_object) { - if (zend_parse_parameters(ZEND_NUM_ARGS() , "S|a", &transaction_id, &headers) == FAILURE) { - return; -- } -+ } - FETCH_STOMP_OBJECT; - } else { - zval *arg; -@@ -1091,19 +1091,19 @@ PHP_FUNCTION(stomp_abort) - } - /* }}} */ - --/* {{{ _php_stomp_acknowledgment -+/* {{{ _php_stomp_acknowledgment - */ - static void _php_stomp_acknowledgment(INTERNAL_FUNCTION_PARAMETERS, char *cmd) { - zval *stomp_object = getThis(); - zval *msg, *headers = NULL; - stomp_t *stomp = NULL; -- stomp_frame_t frame = {0}; -+ stomp_frame_t frame = {0}; - int success = 0; - - if (stomp_object) { - if (zend_parse_parameters(ZEND_NUM_ARGS() , "z|a!", &msg, &headers) == FAILURE) { - return; -- } -+ } - FETCH_STOMP_OBJECT; - } else { - zval *arg; -@@ -1135,7 +1135,7 @@ static void _php_stomp_acknowledgment(INTERNAL_FUNCTION_PARAMETERS, char *cmd) { - CLEAR_FRAME(frame); - RETURN_FALSE; - } -- -+ - if (stomp_send(stomp, &frame ) > 0) { - success = stomp_valid_receipt(stomp, &frame); - } -@@ -1161,7 +1161,7 @@ PHP_FUNCTION(stomp_nack) - } - /* }}} */ - --/* {{{ proto string Stomp::error() -+/* {{{ proto string Stomp::error() - Get the last error message */ - PHP_FUNCTION(stomp_error) - { -@@ -1205,7 +1205,7 @@ PHP_FUNCTION(stomp_set_read_timeout) - if (zend_parse_parameters(ZEND_NUM_ARGS() , "l|l", &sec, &usec) == FAILURE) { - return; - } -- FETCH_STOMP_OBJECT; -+ FETCH_STOMP_OBJECT; - } else { - zval *arg; - if (zend_parse_parameters(ZEND_NUM_ARGS() , "rl|l", &arg, &sec, &usec) == FAILURE) { -@@ -1219,14 +1219,14 @@ PHP_FUNCTION(stomp_set_read_timeout) - } - /* }}} */ - --/* {{{ proto array Stomp::getTimeout() -+/* {{{ proto array Stomp::getTimeout() - Get the timeout */ - PHP_FUNCTION(stomp_get_read_timeout) - { - zval *stomp_object = getThis(); - stomp_t *stomp = NULL; - if (stomp_object) { -- FETCH_STOMP_OBJECT; -+ FETCH_STOMP_OBJECT; - } else { - zval *arg; - if (zend_parse_parameters(ZEND_NUM_ARGS() , "r", &arg) == FAILURE) { -@@ -1270,7 +1270,7 @@ PHP_METHOD(stompframe, __construct) - Get error details */ - PHP_METHOD(stompexception, getDetails) - { -- zval *object = getThis(); -+ zval *object = getThis(); - zval rv, *details = zend_read_property(stomp_ce_exception, object, "details", sizeof("details")-1, 1, &rv); - RETURN_STR(zval_get_string(details)); - } -diff --git a/php_stomp.h b/php_stomp.h -index 805b9f6..fdaaa3e 100644 ---- a/php_stomp.h -+++ b/php_stomp.h -@@ -24,7 +24,7 @@ - typedef struct _stomp_object { - stomp_t *stomp; - zend_object std; --} stomp_object_t; -+} stomp_object_t; - - #define PHP_STOMP_EXTNAME "Stomp" - #define PHP_STOMP_VERSION "2.0.2" -@@ -104,7 +104,7 @@ ZEND_END_MODULE_GLOBALS(stomp) - #define STOMP_G(v) TSRMG(stomp_globals_id, zend_stomp_globals *, v) - #else - #define STOMP_G(v) (stomp_globals.v) --#endif -+#endif - - #endif /* PHP_STOMP_H */ - -diff --git a/stomp.h b/stomp.h -index 19bd8dd..1a422b7 100644 ---- a/stomp.h -+++ b/stomp.h -@@ -40,7 +40,7 @@ typedef struct _stomp_options { - long read_timeout_usec; - #if HAVE_STOMP_SSL - int use_ssl; --#endif -+#endif - } stomp_options_t; - - typedef struct _stomp_frame { -@@ -57,7 +57,7 @@ typedef struct _stomp_frame_stack { - } stomp_frame_stack_t; - - typedef struct _stomp { -- php_socket_t fd; -+ php_socket_t fd; - php_sockaddr_storage localaddr; - stomp_options_t options; - char *host; -diff --git a/tests/002-version.phpt b/tests/002-version.phpt -index d3779aa..6e30db1 100644 ---- a/tests/002-version.phpt -+++ b/tests/002-version.phpt -@@ -3,7 +3,7 @@ Test stomp_version() - --SKIPIF-- - - --FILE-- -- - --EXPECTF-- -diff --git a/tests/003-connect/001.phpt b/tests/003-connect/001.phpt -index 31b48c1..1e3c968 100644 ---- a/tests/003-connect/001.phpt -+++ b/tests/003-connect/001.phpt -@@ -3,7 +3,7 @@ Test stomp_connect() - URI validation - --SKIPIF-- - - --FILE-- -- - --FILE-- -- - --FILE-- -- - --FILE-- -- - --FILE-- -- - --EXPECTF-- -diff --git a/tests/005-close/002.phpt b/tests/005-close/002.phpt -index b24c197..b3dbd95 100644 ---- a/tests/005-close/002.phpt -+++ b/tests/005-close/002.phpt -@@ -1,12 +1,12 @@ - --TEST-- - Test stomp_close() - --SKIPIF-- -- - --FILE-- -- - --FILE-- -- - --FILE-- -- - --FILE-- --send('/queue/test-06', 'A real message', array('receipt' => 'message-12345'))); -diff --git a/tests/007-subscribe/001.phpt b/tests/007-subscribe/001.phpt -index 644c404..8d190dd 100644 ---- a/tests/007-subscribe/001.phpt -+++ b/tests/007-subscribe/001.phpt -@@ -6,7 +6,7 @@ $require_connection = true; - include dirname(__DIR__) . "/skipif.inc"; - ?> - --FILE-- -- - --FILE-- -- - --FILE-- -- - --FILE-- -- - --FILE-- -- - --FILE-- -- - --FILE-- -- - --FILE-- -- -Date: Fri, 25 Sep 2020 16:06:39 +0200 -Subject: [PATCH 1/2] Fix compatibility with PHP 8 - cleanup remaining TSRMLS - macros - fix read/update_property parameters - adapt test suite for exception - in arg. parsing - fix callback - ---- - php_stomp.c | 38 ++++++++++++++++++++-------------- - stomp.c | 6 +++--- - stomp.h | 4 ++-- - tests/003-connect/003.phpt | 2 +- - tests/005-close/001.phpt | 8 +++++-- - tests/007-subscribe/001.phpt | 2 +- - tests/008-unsubscribe/001.phpt | 2 +- - tests/010-timeout/001.phpt | 24 ++++++++++++--------- - tests/010-timeout/002.phpt | 26 ++++++++++++++--------- - 9 files changed, 67 insertions(+), 45 deletions(-) - -diff --git a/php_stomp.c b/php_stomp.c -index 0dcefed..b99a9ff 100644 ---- a/php_stomp.c -+++ b/php_stomp.c -@@ -95,7 +95,7 @@ - zval _object, *object = &_object; \ - THROW_STOMP_EXCEPTION(object, errno, msg) \ - if (details) { \ -- zend_update_property_string(stomp_ce_exception, object, "details", sizeof("details")-1, (char *) details ); \ -+ zend_update_property_string(stomp_ce_exception, OBJ_FOR_PROP(object), "details", sizeof("details")-1, (char *) details ); \ - } \ - } - -@@ -105,6 +105,12 @@ - #define STOMP_URL_STR(a) ZSTR_VAL(a) - #endif - -+#if PHP_VERSION_ID < 80000 -+#define OBJ_FOR_PROP(zv) (zv) -+#else -+#define OBJ_FOR_PROP(zv) Z_OBJ_P(zv) -+#endif -+ - static int le_stomp; - static zend_object_handlers stomp_obj_handlers; - -@@ -562,7 +568,7 @@ PHP_FUNCTION(stomp_connect) - zval excobj; - THROW_STOMP_EXCEPTION(&excobj, stomp->errnum, stomp->error); - if (stomp->error_details) { -- zend_update_property_string(stomp_ce_exception, &excobj, "details", sizeof("details")-1, stomp->error_details ); -+ zend_update_property_string(stomp_ce_exception, OBJ_FOR_PROP(&excobj), "details", sizeof("details")-1, stomp->error_details ); - } - return; - } -@@ -576,7 +582,7 @@ PHP_FUNCTION(stomp_connect) - if ((error_msg = zend_hash_str_find(res->headers, ZEND_STRL("message"))) != NULL) { - THROW_STOMP_EXCEPTION(&excobj, 0, ZSTR_VAL(Z_STR_P(error_msg))); - if (res->body) { -- zend_update_property_string(stomp_ce_exception, &excobj, "details", sizeof("details")-1, (char *) res->body ); -+ zend_update_property_string(stomp_ce_exception, OBJ_FOR_PROP(&excobj), "details", sizeof("details")-1, (char *) res->body ); - } - } - stomp_free_frame(res); -@@ -733,17 +739,17 @@ PHP_FUNCTION(stomp_send) - frame.body_length = Z_STRLEN_P(msg); - } else if (Z_TYPE_P(msg) == IS_OBJECT && instanceof_function(Z_OBJCE_P(msg), stomp_ce_frame )) { - zval *frame_obj_prop = NULL; -- frame_obj_prop = zend_read_property(stomp_ce_frame, msg, "command", sizeof("command")-1, 1, &rv); -+ frame_obj_prop = zend_read_property(stomp_ce_frame, OBJ_FOR_PROP(msg), "command", sizeof("command")-1, 1, &rv); - if (Z_TYPE_P(frame_obj_prop) == IS_STRING) { - frame.command = Z_STRVAL_P(frame_obj_prop); - frame.command_length = Z_STRLEN_P(frame_obj_prop); - } -- frame_obj_prop = zend_read_property(stomp_ce_frame, msg, "body", sizeof("body")-1, 1, &rv); -+ frame_obj_prop = zend_read_property(stomp_ce_frame, OBJ_FOR_PROP(msg), "body", sizeof("body")-1, 1, &rv); - if (Z_TYPE_P(frame_obj_prop) == IS_STRING) { - frame.body = Z_STRVAL_P(frame_obj_prop); - frame.body_length = Z_STRLEN_P(frame_obj_prop); - } -- frame_obj_prop = zend_read_property(stomp_ce_frame, msg, "headers", sizeof("headers")-1, 1, &rv); -+ frame_obj_prop = zend_read_property(stomp_ce_frame, OBJ_FOR_PROP(msg), "headers", sizeof("headers")-1, 1, &rv); - if (Z_TYPE_P(frame_obj_prop) == IS_ARRAY) { - FRAME_HEADER_FROM_HASHTABLE(frame.headers, Z_ARRVAL_P(frame_obj_prop)); - } -@@ -928,7 +934,7 @@ PHP_FUNCTION(stomp_read_frame) - zval excobj; - THROW_STOMP_EXCEPTION(&excobj, 0, Z_STRVAL_P(error_msg)); - if (res->body) { -- zend_update_property_string(stomp_ce_exception, &excobj, ZEND_STRL("details"), (char *)res->body ); -+ zend_update_property_string(stomp_ce_exception, OBJ_FOR_PROP(&excobj), ZEND_STRL("details"), (char *)res->body ); - } - stomp_free_frame(res); - RETURN_FALSE; -@@ -966,10 +972,11 @@ PHP_FUNCTION(stomp_read_frame) - ZVAL_NULL(&body); - } - -+ memset(&fci, 0, sizeof(fci)); -+ memset(&fcc, 0, sizeof(fcc)); - fci.size = sizeof(fci); - #if (PHP_MAJOR_VERSION == 7 && PHP_MINOR_VERSION == 0) - fci.function_table = &ce->function_table; -- fci.symbol_table = NULL; - #endif - /* PARAMS */ - fci.param_count = 3; -@@ -981,8 +988,9 @@ PHP_FUNCTION(stomp_read_frame) - ZVAL_UNDEF(&fci.function_name); - fci.object = Z_OBJ_P(return_value); - fci.retval = &retval; -+#if PHP_VERSION_ID < 80000 - fci.no_separation = 1; -- -+#endif - #if PHP_VERSION_ID < 70300 - fcc.initialized = 1; - #endif -@@ -995,7 +1003,7 @@ PHP_FUNCTION(stomp_read_frame) - fcc.object = Z_OBJ_P(return_value); - - if (zend_call_function(&fci, &fcc ) == FAILURE) { -- 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)); -+ 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)); - } else { - zval_ptr_dtor(&retval); - } -@@ -1125,7 +1133,7 @@ static void _php_stomp_acknowledgment(INTERNAL_FUNCTION_PARAMETERS, char *cmd) { - } else if (Z_TYPE_P(msg) == IS_OBJECT && instanceof_function(Z_OBJCE_P(msg), stomp_ce_frame )) { - zval *frame_obj_prop, rv; - -- frame_obj_prop = zend_read_property(stomp_ce_frame, msg, "headers", sizeof("headers")-1, 1, &rv); -+ frame_obj_prop = zend_read_property(stomp_ce_frame, OBJ_FOR_PROP(msg), "headers", sizeof("headers")-1, 1, &rv); - if (Z_TYPE_P(frame_obj_prop) == IS_ARRAY) { - FRAME_HEADER_FROM_HASHTABLE(frame.headers, Z_ARRVAL_P(frame_obj_prop)); - } -@@ -1255,13 +1263,13 @@ PHP_METHOD(stompframe, __construct) - } - - if (command_length > 0) { -- zend_update_property_stringl(stomp_ce_frame, object, "command", sizeof("command")-1, command, command_length ); -+ zend_update_property_stringl(stomp_ce_frame, OBJ_FOR_PROP(object), "command", sizeof("command")-1, command, command_length ); - } - if (headers) { -- zend_update_property(stomp_ce_frame, object, "headers", sizeof("headers")-1, headers ); -+ zend_update_property(stomp_ce_frame, OBJ_FOR_PROP(object), "headers", sizeof("headers")-1, headers ); - } - if (body_length > 0) { -- zend_update_property_stringl(stomp_ce_frame, object, "body", sizeof("body")-1, body, body_length ); -+ zend_update_property_stringl(stomp_ce_frame, OBJ_FOR_PROP(object), "body", sizeof("body")-1, body, body_length ); - } - } - /* }}} */ -@@ -1271,7 +1279,7 @@ PHP_METHOD(stompframe, __construct) - PHP_METHOD(stompexception, getDetails) - { - zval *object = getThis(); -- zval rv, *details = zend_read_property(stomp_ce_exception, object, "details", sizeof("details")-1, 1, &rv); -+ zval rv, *details = zend_read_property(stomp_ce_exception, OBJ_FOR_PROP(object), "details", sizeof("details")-1, 1, &rv); - RETURN_STR(zval_get_string(details)); - } - /* }}} */ -diff --git a/stomp.c b/stomp.c -index d83a4e6..6e77ede 100644 ---- a/stomp.c -+++ b/stomp.c -@@ -34,7 +34,7 @@ extern zend_class_entry *stomp_ce_exception; - - /* {{{ DEBUG */ - #if PHP_DEBUG --static void print_stomp_frame(stomp_frame_t *frame TSRMLS_DC) { -+static void print_stomp_frame(stomp_frame_t *frame) { - php_printf("------ START FRAME ------\n"); - php_printf("%s\n", frame->command); - /* Headers */ -@@ -186,7 +186,7 @@ int stomp_writable(stomp_t *stomp) - - /* {{{ stomp_connect - */ --int stomp_connect(stomp_t *stomp, const char *host, unsigned short port TSRMLS_DC) -+int stomp_connect(stomp_t *stomp, const char *host, unsigned short port) - { - char error[1024]; - socklen_t size; -@@ -297,7 +297,7 @@ void stomp_close(stomp_t *stomp) - - /* {{{ stomp_send - */ --int stomp_send(stomp_t *stomp, stomp_frame_t *frame TSRMLS_DC) -+int stomp_send(stomp_t *stomp, stomp_frame_t *frame) - { - smart_str buf = {0}; - -diff --git a/stomp.h b/stomp.h -index 1a422b7..e4d02b3 100644 ---- a/stomp.h -+++ b/stomp.h -@@ -79,9 +79,9 @@ typedef struct _stomp { - } stomp_t; - - stomp_t *stomp_init(); --int stomp_connect(stomp_t *stomp, const char *host, unsigned short port TSRMLS_DC); -+int stomp_connect(stomp_t *stomp, const char *host, unsigned short port); - void stomp_close(stomp_t *stomp); --int stomp_send(stomp_t *connection, stomp_frame_t *frame TSRMLS_DC); -+int stomp_send(stomp_t *connection, stomp_frame_t *frame); - stomp_frame_t *stomp_read_frame_ex(stomp_t *connection, int use_stack); - int stomp_valid_receipt(stomp_t *connection, stomp_frame_t *frame); - int stomp_select_ex(stomp_t *connection, const long int sec, const long int usec); -diff --git a/tests/003-connect/003.phpt b/tests/003-connect/003.phpt -index b3de8d6..ba60e15 100644 ---- a/tests/003-connect/003.phpt -+++ b/tests/003-connect/003.phpt -@@ -2,7 +2,7 @@ - Test stomp_connect() - Test error on CONNECT - --SKIPIF-- - - --FILE-- - - --FILE-- - getMessage() . PHP_EOL; -+} - ?> - --EXPECTF-- --Warning: stomp_close() expects parameter 1 to be resource, null given in %s on line %d -+%stomp_close()%s1%s null %s -diff --git a/tests/007-subscribe/001.phpt b/tests/007-subscribe/001.phpt -index 8d190dd..494471c 100644 ---- a/tests/007-subscribe/001.phpt -+++ b/tests/007-subscribe/001.phpt -@@ -16,7 +16,7 @@ $s->subscribe('/queue/test', 'string'); - --EXPECTF-- - Warning: Stomp::subscribe(): Destination can not be empty in %s007-subscribe%c001.php on line %d - --Fatal error: Uncaught TypeError: Argument 2 passed to Stomp::subscribe() must be of the type array, string given in %s007-subscribe%c001.php:%d -+Fatal error: Uncaught TypeError: %s, string given in %s007-subscribe%c001.php:%d - Stack trace: - #0 %s001.php(%d): Stomp->subscribe('/queue/test', 'string') - #1 {main} -diff --git a/tests/008-unsubscribe/001.phpt b/tests/008-unsubscribe/001.phpt -index c1200eb..7d1b50f 100644 ---- a/tests/008-unsubscribe/001.phpt -+++ b/tests/008-unsubscribe/001.phpt -@@ -17,7 +17,7 @@ $s->unsubscribe('/queue/test', 'string'); - --EXPECTF-- - Warning: Stomp::unsubscribe(): Destination can not be empty in %s008-unsubscribe%c001.php on line %d - --Fatal error: Uncaught TypeError: Argument 2 passed to Stomp::unsubscribe() must be of the type array, string given in %s008-unsubscribe%c001.php:%d -+Fatal error: Uncaught TypeError: %s2%s string given in %s008-unsubscribe%c001.php:%d - Stack trace: - #0 %s(%d): Stomp->unsubscribe('/queue/test', 'string') - #1 {main} -diff --git a/tests/010-timeout/001.phpt b/tests/010-timeout/001.phpt -index 7389f70..b9886db 100644 ---- a/tests/010-timeout/001.phpt -+++ b/tests/010-timeout/001.phpt -@@ -25,13 +25,21 @@ var_dump($s->setReadTimeout(10, 5)); - // Third test, read supposed to return 10.5 - var_dump($s->getReadTimeout()); - --// Set read timout with the first param as a string, supposed to trigger a warning --var_dump($s->setReadTimeout('')); -+try { -+ // Set read timout with the first param as a string, supposed to trigger a warning/exception -+ var_dump($s->setReadTimeout('')); -+} catch (TypeError $e) { -+ echo $e->getMessage() . PHP_EOL; -+} - // Fourth test, read supposed to get the last value set : 10.5 - var_dump($s->getReadTimeout()); - --// Set read timout with the second param as a string, supposed to trigger a warning --var_dump($s->setReadTimeout(10, '')); -+try { -+ // Set read timout with the second param as a string, supposed to trigger a warning/exception -+ var_dump($s->setReadTimeout(10, '')); -+} catch (TypeError $e) { -+ echo $e->getMessage() . PHP_EOL; -+} - // Fourth test, read supposed to get the last value set : 10.5 - var_dump($s->getReadTimeout()); - -@@ -64,18 +72,14 @@ array(2) { - ["usec"]=> - int(5) - } -- --Warning: Stomp::setReadTimeout() expects parameter 1 to be long, string given in %s on line %d --NULL -+%AStomp::setReadTimeout()%s1%s string given%A - array(2) { - ["sec"]=> - int(10) - ["usec"]=> - int(5) - } -- --Warning: Stomp::setReadTimeout() expects parameter 2 to be long, string given in %s on line %d --NULL -+%AStomp::setReadTimeout()%s2%s string given%A - array(2) { - ["sec"]=> - int(10) -diff --git a/tests/010-timeout/002.phpt b/tests/010-timeout/002.phpt -index a6a9b4a..c22dedf 100644 ---- a/tests/010-timeout/002.phpt -+++ b/tests/010-timeout/002.phpt -@@ -25,13 +25,23 @@ var_dump(stomp_set_read_timeout($link, 10, 5)); - // Third test, read supposed to return 10.5 - var_dump(stomp_get_read_timeout($link)); - --// Set read timout with the first param as a string, supposed to trigger a warning --var_dump(stomp_set_read_timeout($link, '')); -+try { -+ // Set read timout with the first param as a string, supposed to trigger a warning on PHP 7 -+ // supposed to trigger an exception on PHP 8 -+ var_dump(stomp_set_read_timeout($link, '')); -+} catch (TypeError $e) { -+ echo $e->getMessage() . PHP_EOL; -+} - // Fourth test, read supposed to get the last value set : 10.5 - var_dump(stomp_get_read_timeout($link)); - --// Set read timout with the second param as a string, supposed to trigger a warning --var_dump(stomp_set_read_timeout($link, 10, '')); -+try { -+ // Set read timout with the second param as a string, supposed to trigger a warning on PHP 7 -+ // supposed to trigger an exception on PHP 8 -+ var_dump(stomp_set_read_timeout($link, 10, '')); -+} catch (TypeError $e) { -+ echo $e->getMessage() . PHP_EOL; -+} - // Fourth test, read supposed to get the last value set : 10.5 - var_dump(stomp_get_read_timeout($link)); - -@@ -64,18 +74,14 @@ array(2) { - ["usec"]=> - int(5) - } -- --Warning: stomp_set_read_timeout() expects parameter 2 to be long, string given in %s on line %d --NULL -+%Astomp_set_read_timeout()%s2%S string given%A - array(2) { - ["sec"]=> - int(10) - ["usec"]=> - int(5) - } -- --Warning: stomp_set_read_timeout() expects parameter 3 to be long, string given in %s on line %d --NULL -+%Astomp_set_read_timeout()%s3%s string given%A - array(2) { - ["sec"]=> - int(10) - diff --git a/stomp-upstream.patch b/stomp-upstream.patch new file mode 100644 index 0000000..c356df7 --- /dev/null +++ b/stomp-upstream.patch @@ -0,0 +1,1743 @@ +From 7b066620afe3368662e316e86242d0087de8a44e Mon Sep 17 00:00:00 2001 +From: Peter Kokot +Date: Sat, 30 Jun 2018 16:44:34 +0200 +Subject: [PATCH] Remove unused Git attributes ident + +The $Id$ keywords were used in Subversion where they can be substituted +with filename, last revision number change, last changed date, and last +user who changed it. + +In Git this functionality is different and can be done with Git attribute +ident. These need to be defined manually for each file in the +.gitattributes file and are afterwards replaced with 40-character +hexadecimal blob object name which is based only on the particular file +contents. + +This patch simplifes handling of $Id$ keywords by removing them since +they are not used anymore. +--- + config.m4 | 1 - + config.w32 | 1 - + php_stomp.c | 2 -- + php_stomp.h | 2 -- + stomp.c | 2 -- + stomp.h | 2 -- + 6 files changed, 10 deletions(-) + +diff --git a/config.m4 b/config.m4 +index 8a9c36b..f700f27 100644 +--- a/config.m4 ++++ b/config.m4 +@@ -1,4 +1,3 @@ +-dnl $Id$ + dnl config.m4 for extension stomp + + PHP_ARG_ENABLE(stomp, whether to enable stomp support, +diff --git a/config.w32 b/config.w32 +index 091e00b..ba3096b 100644 +--- a/config.w32 ++++ b/config.w32 +@@ -1,4 +1,3 @@ +-// $Id$ + // vim:ft=javascript + + ARG_ENABLE("stomp", "enable stomp support", "no"); +diff --git a/php_stomp.c b/php_stomp.c +index 9442011..080298f 100644 +--- a/php_stomp.c ++++ b/php_stomp.c +@@ -16,8 +16,6 @@ + +----------------------------------------------------------------------+ + */ + +-/* $Id$ */ +- + #ifdef HAVE_CONFIG_H + #include "config.h" + #endif +diff --git a/php_stomp.h b/php_stomp.h +index b799119..805b9f6 100644 +--- a/php_stomp.h ++++ b/php_stomp.h +@@ -16,8 +16,6 @@ + +----------------------------------------------------------------------+ + */ + +-/* $Id$ */ +- + #ifndef PHP_STOMP_H + #define PHP_STOMP_H + +diff --git a/stomp.c b/stomp.c +index 2f71606..d83a4e6 100644 +--- a/stomp.c ++++ b/stomp.c +@@ -16,8 +16,6 @@ + +----------------------------------------------------------------------+ + */ + +-/* $Id$ */ +- + #ifdef HAVE_CONFIG_H + #include "config.h" + #endif +diff --git a/stomp.h b/stomp.h +index a47787f..19bd8dd 100644 +--- a/stomp.h ++++ b/stomp.h +@@ -16,8 +16,6 @@ + +----------------------------------------------------------------------+ + */ + +-/* $Id$ */ +- + #ifndef _STOMP_H_ + #define _STOMP_H_ + + +From 684706756972bb75fec025ec9d66c3fc99ed5199 Mon Sep 17 00:00:00 2001 +From: Peter Kokot +Date: Wed, 3 Oct 2018 09:43:57 +0200 +Subject: [PATCH] Trim trailing whitespace + +--- + LICENSE | 26 ++++----- + README | 2 +- + TODO | 2 +- + config.m4 | 2 +- + doc/classes.php | 48 ++++++++-------- + doc/functions.php | 44 +++++++-------- + php_stomp.c | 94 ++++++++++++++++---------------- + php_stomp.h | 4 +- + stomp.h | 4 +- + tests/002-version.phpt | 2 +- + tests/003-connect/001.phpt | 2 +- + tests/003-connect/002.phpt | 4 +- + tests/003-connect/003.phpt | 2 +- + tests/004-getSessionId/001.phpt | 4 +- + tests/005-close/001.phpt | 4 +- + tests/005-close/002.phpt | 4 +- + tests/006-send/001.phpt | 2 +- + tests/006-send/002.phpt | 2 +- + tests/006-send/003.phpt | 2 +- + tests/007-subscribe/001.phpt | 2 +- + tests/008-unsubscribe/001.phpt | 2 +- + tests/009-readFrame/001.phpt | 2 +- + tests/009-readFrame/003.phpt | 4 +- + tests/009-readFrame/004.phpt | Bin 433 -> 432 bytes + tests/009-readFrame/006.phpt | 2 +- + tests/010-timeout/001.phpt | 4 +- + tests/010-timeout/002.phpt | 4 +- + tests/011-commit/001.phpt | 2 +- + tests/skipif.inc | 2 +- + 29 files changed, 139 insertions(+), 139 deletions(-) + +diff --git a/LICENSE b/LICENSE +index 6059c80..92ee907 100644 +--- a/LICENSE ++++ b/LICENSE +@@ -1,7 +1,7 @@ +--------------------------------------------------------------------- ++-------------------------------------------------------------------- + The PHP License, version 3.01 + Copyright (c) 1999 - 2014 The PHP Group. All rights reserved. +--------------------------------------------------------------------- ++-------------------------------------------------------------------- + + Redistribution and use in source and binary forms, with or without + modification, is permitted provided that the following conditions +@@ -9,22 +9,22 @@ are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +- ++ + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. +- ++ + 3. The name "PHP" must not be used to endorse or promote products + derived from this software without prior written permission. For + written permission, please contact group@php.net. +- ++ + 4. Products derived from this software may not be called "PHP", nor + may "PHP" appear in their name, without prior written permission + from group@php.net. You may indicate that your software works in + conjunction with PHP by saying "Foo for PHP" instead of calling + it "PHP Foo" or "phpfoo" +- ++ + 5. The PHP Group may publish revised and/or new versions of the + license from time to time. Each version will be given a + distinguishing version number. +@@ -41,27 +41,27 @@ are met: + "This product includes PHP software, freely available from + ". + +-THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND ++THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND + ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A ++THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP +-DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, ++INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + OF THE POSSIBILITY OF SUCH DAMAGE. + +--------------------------------------------------------------------- ++-------------------------------------------------------------------- + + This software consists of voluntary contributions made by many + individuals on behalf of the PHP Group. + + The PHP Group can be contacted via Email at group@php.net. + +-For more information on the PHP Group and the PHP project, ++For more information on the PHP Group and the PHP project, + please see . + + PHP includes the Zend Engine, freely available at +diff --git a/README b/README +index 6511d8b..a0c1953 100644 +--- a/README ++++ b/README +@@ -1,7 +1,7 @@ + stomp + ===== + +-This extension allows php applications to communicate with any Stomp compliant Message Broker(s) through easy object ++This extension allows php applications to communicate with any Stomp compliant Message Broker(s) through easy object + oriented and procedural interfaces. + + This extension currently implements STOMP 1.0 protocol: https://stomp.github.io/stomp-specification-1.0.html +diff --git a/config.m4 b/config.m4 +index f700f27..cbeb71b 100644 +--- a/config.m4 ++++ b/config.m4 +@@ -16,7 +16,7 @@ if test "$PHP_STOMP" != "no"; then + [ + AC_DEFINE(HAVE_STOMP_SSL,1,[ ]) + ], [ +- AC_MSG_ERROR([OpenSSL libraries not found. ++ AC_MSG_ERROR([OpenSSL libraries not found. + + Check the path given to --with-openssl-dir and output in config.log) + ]) +diff --git a/doc/classes.php b/doc/classes.php +index 0cfc554..06c50a0 100644 +--- a/doc/classes.php ++++ b/doc/classes.php +@@ -4,7 +4,7 @@ class Stomp { + + /** + * Connect to server +- * ++ * + * @param string $broker The broker URI + * @param string $username The username + * @param string $password The password +@@ -15,7 +15,7 @@ public function __construct($broker = null, $username = null, $password = null, + + /** + * Get the current stomp session ID +- * ++ * + * @return string stomp session ID if it exists, or FALSE otherwise + */ + public function getSessionId() { +@@ -24,28 +24,28 @@ public function getSessionId() { + /** + * Close stomp connection + * +- * @return boolean TRUE on success, or FALSE on failure ++ * @return boolean TRUE on success, or FALSE on failure + */ + public function disconnect() { + } + +- /** ++ /** + * Sends a message to a destination in the messaging system +- * +- * @param string $destination indicates where to send the message ++ * ++ * @param string $destination indicates where to send the message + * @param string|StompFrame $msg message to be sent + * @param array $headers additional headers (example: receipt). +- * @return boolean TRUE on success, or FALSE on failure ++ * @return boolean TRUE on success, or FALSE on failure + */ + public function send($destination, $msg, array $headers = array()) { + } + + /** + * Register to listen to a given destination +- * +- * @param string $destination indicates which destination to subscribe to ++ * ++ * @param string $destination indicates which destination to subscribe to + * @param array $headers additional headers (example: receipt). +- * @return boolean TRUE on success, or FALSE on failure ++ * @return boolean TRUE on success, or FALSE on failure + */ + public function subscribe($destination, array $headers = array()) { + } +@@ -55,14 +55,14 @@ public function subscribe($destination, array $headers = array()) { + * + * @param string $destination indicates which subscription to remove + * @param array $headers additional headers (example: receipt). +- * @return boolean TRUE on success, or FALSE on failure ++ * @return boolean TRUE on success, or FALSE on failure + */ + public function unsubscribe($destination, array $headers = array()) { + } + + /** + * Indicate whether or not there is a frame ready to read +- * ++ * + * @return boolean TRUE if there is one, or FALSE otherwise + */ + public function hasFrame() { +@@ -81,7 +81,7 @@ public function readFrame($className = 'stompFrame') { + * Start a transaction + * + * @param string $transaction_id transaction id +- * @return boolean TRUE on success, or FALSE on failure ++ * @return boolean TRUE on success, or FALSE on failure + */ + public function begin($transaction_id) { + } +@@ -90,26 +90,26 @@ public function begin($transaction_id) { + * Commit a transaction in progress + * + * @param string $transaction_id transaction id +- * @return boolean TRUE on success, or FALSE on failure ++ * @return boolean TRUE on success, or FALSE on failure + */ +- public function commit($transaction_id) { ++ public function commit($transaction_id) { + } + + /** + * Roll back a transaction in progress + * + * @param string $transaction_id transaction id +- * @return boolean TRUE on success, or FALSE on failure ++ * @return boolean TRUE on success, or FALSE on failure + */ + public function abort($transaction_id) { + } + + /** + * Acknowledge consumption of a message from a subscription using client acknowledgment +- * ++ * + * @param string|StompFrame $msg message/messageId to be acknowledged + * @param array $headers additional headers (example: receipt). +- * @return boolean TRUE on success, or FALSE on failure ++ * @return boolean TRUE on success, or FALSE on failure + */ + public function ack($msg, array $headers = array()) { + } +@@ -124,7 +124,7 @@ public function error() { + + /** + * Set timeout +- * ++ * + * @param int $seconds the seconds part of the timeout to be set + * @param int $microseconds the microseconds part of the timeout to be set + * @return void +@@ -134,16 +134,16 @@ public function setTimeout($seconds, $microseconds = 0) { + + /** + * Get timeout +- * ++ * + * @return array Array with timeout informations + */ + public function getTimeout() { +- } ++ } + + } + + class StompFrame { +- ++ + /** + * Frame Command + * @var String +@@ -164,11 +164,11 @@ class StompFrame { + } + + class StompException extends Exception { +- ++ + /** + * Get the stomp server error details + * +- * @return string ++ * @return string + */ + public function getDetails() { + } +diff --git a/doc/functions.php b/doc/functions.php +index 98486fc..57ae424 100644 +--- a/doc/functions.php ++++ b/doc/functions.php +@@ -2,7 +2,7 @@ + + /** + * Get the current version of the stomp extension +- * ++ * + * @return string version + */ + function stomp_version() { +@@ -10,19 +10,19 @@ function stomp_version() { + + /** + * Connect to server +- * ++ * + * @param string $broker broker URI + * @param string $username The username + * @param string $password The password + * @param array $headers additional headers (example: receipt). +- * @return Ressource stomp connection identifier on success, or FALSE on failure ++ * @return Ressource stomp connection identifier on success, or FALSE on failure + */ + function stomp_connect($broker = null, $username = null, $password = null, array $headers = array()) { + } + + /** + * Get the current stomp session ID +- * ++ * + * @param ressource $link identifier returned by stomp_connect + * @return string stomp session ID if it exists, or FALSE otherwise + */ +@@ -33,30 +33,30 @@ function stomp_get_session_id($link) { + * Close stomp connection + * + * @param ressource $link identifier returned by stomp_connect +- * @return boolean TRUE on success, or FALSE on failure ++ * @return boolean TRUE on success, or FALSE on failure + */ + function stomp_close($link) { + } + +-/** ++/** + * Sends a message to a destination in the messaging system +- * ++ * + * @param ressource $link identifier returned by stomp_connect +- * @param string $destination indicates where to send the message ++ * @param string $destination indicates where to send the message + * @param string|StompFrame $msg message to be sent + * @param array $headers additional headers (example: receipt). +- * @return boolean TRUE on success, or FALSE on failure ++ * @return boolean TRUE on success, or FALSE on failure + */ + function stomp_send($link, $destination, $msg, array $headers = array()) { + } + + /** + * Register to listen to a given destination +- * ++ * + * @param ressource $link identifier returned by stomp_connect +- * @param string $destination indicates which destination to subscribe to ++ * @param string $destination indicates which destination to subscribe to + * @param array $headers additional headers (example: receipt). +- * @return boolean TRUE on success, or FALSE on failure ++ * @return boolean TRUE on success, or FALSE on failure + */ + function stomp_subscribe($link, $destination, array $headers = array()) { + } +@@ -67,14 +67,14 @@ function stomp_subscribe($link, $destination, array $headers = array()) { + * @param ressource $link identifier returned by stomp_connect + * @param string $destination indicates which subscription to remove + * @param array $headers additional headers (example: receipt). +- * @return boolean TRUE on success, or FALSE on failure ++ * @return boolean TRUE on success, or FALSE on failure + */ + function stomp_unsubscribe($link, $destination, array $headers = array()) { + } + + /** + * Indicate whether or not there is a frame ready to read +- * ++ * + * @param ressource $link identifier returned by stomp_connect + * @return boolean TRUE if there is one, or FALSE otherwise + */ +@@ -95,7 +95,7 @@ function stomp_read_frame($link) { + * + * @param ressource $link identifier returned by stomp_connect + * @param string $transaction_id transaction id +- * @return boolean TRUE on success, or FALSE on failure ++ * @return boolean TRUE on success, or FALSE on failure + */ + function stomp_begin($link, $transaction_id) { + } +@@ -105,9 +105,9 @@ function stomp_begin($link, $transaction_id) { + * + * @param ressource $link identifier returned by stomp_connect + * @param string $transaction_id transaction id +- * @return boolean TRUE on success, or FALSE on failure ++ * @return boolean TRUE on success, or FALSE on failure + */ +-function stomp_commit($link, $transaction_id) { ++function stomp_commit($link, $transaction_id) { + } + + /** +@@ -115,18 +115,18 @@ function stomp_commit($link, $transaction_id) { + * + * @param ressource $link identifier returned by stomp_connect + * @param string $transaction_id transaction id +- * @return boolean TRUE on success, or FALSE on failure ++ * @return boolean TRUE on success, or FALSE on failure + */ + function stomp_abort($link, $transaction_id) { + } + + /** + * Acknowledge consumption of a message from a subscription using client acknowledgment +- * ++ * + * @param ressource $link identifier returned by stomp_connect + * @param string|StompFrame $msg message/messageId to be acknowledged + * @param array $headers additional headers (example: receipt). +- * @return boolean TRUE on success, or FALSE on failure ++ * @return boolean TRUE on success, or FALSE on failure + */ + function stomp_ack($link, $msg, array $headers = array()) { + } +@@ -142,7 +142,7 @@ function stomp_error($link) { + + /** + * Set timeout +- * ++ * + * @param ressource $link identifier returned by stomp_connect + * @param int $seconds the seconds part of the timeout to be set + * @param int $microseconds the microseconds part of the timeout to be set +@@ -153,7 +153,7 @@ function stomp_set_timeout($link, $seconds, $microseconds = 0) { + + /** + * Get timeout +- * ++ * + * @param ressource $link identifier returned by stomp_connect + * @return array Array with timeout informations + */ +diff --git a/php_stomp.c b/php_stomp.c +index 080298f..0dcefed 100644 +--- a/php_stomp.c ++++ b/php_stomp.c +@@ -83,7 +83,7 @@ + STOMP_G(error_msg) = estrdup(msg); \ + if (stomp_object) { \ + zend_throw_exception_ex(stomp_ce_exception, errno , msg); \ +- } ++ } + + #define STOMP_ERROR_DETAILS(errno, msg, details) \ + STOMP_G(error_no) = errno; \ +@@ -157,7 +157,7 @@ ZEND_ARG_ARRAY_INFO(0, headers, 1) + ZEND_END_ARG_INFO() + + ZEND_BEGIN_ARG_INFO_EX(stomp_readframe_args, 0, 0, 1) +-ZEND_ARG_INFO(0, link) ++ZEND_ARG_INFO(0, link) + ZEND_ARG_INFO(0, class_name) + ZEND_END_ARG_INFO() + +@@ -213,7 +213,7 @@ ZEND_BEGIN_ARG_INFO_EX(stomp_frame_construct_args, 0, 0, 0) + ZEND_ARG_INFO(0, command) + ZEND_ARG_ARRAY_INFO(0, headers, 1) + ZEND_ARG_INFO(0, body) +-ZEND_END_ARG_INFO() ++ZEND_END_ARG_INFO() + /* }}} */ + + /* {{{ stomp_functions */ +@@ -267,7 +267,7 @@ static zend_function_entry stomp_frame_methods[] = { + PHP_ME(stompframe, __construct, stomp_frame_construct_args, ZEND_ACC_PUBLIC) + {NULL, NULL, NULL} + }; +-/* }}} */ ++/* }}} */ + + /* {{{ stomp_exception_methods[] */ + static zend_function_entry stomp_exception_methods[] = { +@@ -283,7 +283,7 @@ zend_module_entry stomp_module_entry = { + stomp_functions, + PHP_MINIT(stomp), + PHP_MSHUTDOWN(stomp), +- PHP_RINIT(stomp), ++ PHP_RINIT(stomp), + PHP_RSHUTDOWN(stomp), + PHP_MINFO(stomp), + PHP_STOMP_VERSION, +@@ -330,9 +330,9 @@ ZEND_GET_MODULE(stomp) + /* {{{ constructor/destructor */ + static void stomp_send_disconnect(stomp_t *stomp) + { +- stomp_frame_t frame = {0}; ++ stomp_frame_t frame = {0}; + INIT_FRAME(frame, "DISCONNECT"); +- ++ + stomp_send(stomp, &frame ); + CLEAR_FRAME(frame); + } +@@ -342,7 +342,7 @@ static void php_destroy_stomp_res(zend_resource *rsrc) + stomp_t *stomp = (stomp_t *) rsrc->ptr; + stomp_send_disconnect(stomp ); + stomp_close(stomp); +-} ++} + + static zend_object *php_stomp_new(zend_class_entry *ce) + { +@@ -350,7 +350,7 @@ static zend_object *php_stomp_new(zend_class_entry *ce) + + intern = (stomp_object_t *) ecalloc(1, sizeof(stomp_object_t) + zend_object_properties_size(ce)); + intern->stomp = NULL; +- ++ + zend_object_std_init(&intern->std, ce ); + + intern->std.handlers = &stomp_obj_handlers; +@@ -381,7 +381,7 @@ PHP_MINIT_FUNCTION(stomp) + /* Properties */ + zend_declare_property_null(stomp_ce_frame, "command", sizeof("command")-1, ZEND_ACC_PUBLIC ); + zend_declare_property_null(stomp_ce_frame, "headers", sizeof("headers")-1, ZEND_ACC_PUBLIC ); +- zend_declare_property_null(stomp_ce_frame, "body", sizeof("body")-1, ZEND_ACC_PUBLIC ); ++ zend_declare_property_null(stomp_ce_frame, "body", sizeof("body")-1, ZEND_ACC_PUBLIC ); + + /* Register StompException class */ + INIT_CLASS_ENTRY(ce, PHP_STOMP_EXCEPTION_CLASSNAME, stomp_exception_methods); +@@ -399,7 +399,7 @@ PHP_MINIT_FUNCTION(stomp) + + /* {{{ PHP_MSHUTDOWN_FUNCTION */ + PHP_MSHUTDOWN_FUNCTION(stomp) +-{ ++{ + /* Unregister INI entries */ + UNREGISTER_INI_ENTRIES(); + return SUCCESS; +@@ -443,9 +443,9 @@ PHP_MINFO_FUNCTION(stomp) + } + /* }}} */ + +-/* {{{ proto string stomp_version() ++/* {{{ proto string stomp_version() + Get stomp extension version */ +-PHP_FUNCTION(stomp_version) ++PHP_FUNCTION(stomp_version) + { + RETURN_STRINGL(PHP_STOMP_VERSION, sizeof(PHP_STOMP_VERSION)-1); + } +@@ -461,9 +461,9 @@ PHP_FUNCTION(stomp_connect) + zend_string *broker = NULL, *username = NULL, *password = NULL; + php_url *url_parts; + +-#ifdef HAVE_STOMP_SSL ++#ifdef HAVE_STOMP_SSL + int use_ssl = 0; +-#endif ++#endif + + if (zend_parse_parameters(ZEND_NUM_ARGS() , "|SSSa!", &broker, &username, &password, &headers) == FAILURE) { + return; +@@ -478,7 +478,7 @@ PHP_FUNCTION(stomp_connect) + } + + url_parts = php_url_parse_ex(ZSTR_VAL(broker), ZSTR_LEN(broker)); +- ++ + if (!url_parts || !url_parts->host) { + STOMP_ERROR(0, PHP_STOMP_ERR_INVALID_BROKER_URI); + zend_string_release(broker); +@@ -495,7 +495,7 @@ PHP_FUNCTION(stomp_connect) + STOMP_ERROR(0, "SSL DISABLED"); + php_url_free(url_parts); + return; +-#endif ++#endif + } else if (strcmp(STOMP_URL_STR(url_parts->scheme), "tcp") != 0) { + STOMP_ERROR(0, PHP_STOMP_ERR_INVALID_BROKER_URI_SCHEME); + php_url_free(url_parts); +@@ -507,7 +507,7 @@ PHP_FUNCTION(stomp_connect) + + #if HAVE_STOMP_SSL + stomp->options.use_ssl = use_ssl; +-#endif ++#endif + + stomp->options.read_timeout_sec = STOMP_G(read_timeout_sec); + stomp->options.read_timeout_usec = STOMP_G(read_timeout_usec); +@@ -522,7 +522,7 @@ PHP_FUNCTION(stomp_connect) + stomp_frame_t *res; + stomp_frame_t frame = {0}; + int send_status; +- ++ + INIT_FRAME(frame, "CONNECT"); + if (!username) { + username = zend_string_init(STOMP_G(default_username), strlen(STOMP_G(default_username)), 0); +@@ -548,7 +548,7 @@ PHP_FUNCTION(stomp_connect) + ZVAL_STR(&rv, zend_string_copy(password)); + zend_hash_str_add(frame.headers, "passcode", sizeof("passcode"), &rv); + } +- ++ + zend_string_release(username); + zend_string_release(password); + +@@ -607,7 +607,7 @@ PHP_FUNCTION(stomp_connect) + i_obj->stomp = stomp; + RETURN_TRUE; + } +- } ++ } + } else { + STOMP_ERROR_DETAILS(0, stomp->error, stomp->error_details); + } +@@ -617,9 +617,9 @@ PHP_FUNCTION(stomp_connect) + } + /* }}} */ + +-/* {{{ proto string stomp_connect_error() ++/* {{{ proto string stomp_connect_error() + Get the last connection error */ +-PHP_FUNCTION(stomp_connect_error) ++PHP_FUNCTION(stomp_connect_error) + { + if (STOMP_G(error_msg)) { + RETURN_STRING(STOMP_G(error_msg)); +@@ -629,7 +629,7 @@ PHP_FUNCTION(stomp_connect_error) + } + /* }}} */ + +-/* {{{ proto string Stomp::getSessionId() ++/* {{{ proto string Stomp::getSessionId() + Get the current stomp session ID */ + PHP_FUNCTION(stomp_get_session_id) + { +@@ -695,13 +695,13 @@ PHP_FUNCTION(stomp_send) + stomp_t *stomp = NULL; + zend_string *destination; + zval *msg, *headers = NULL, rv; +- stomp_frame_t frame = {0}; ++ stomp_frame_t frame = {0}; + int success = 0; + + if (stomp_object) { + if (zend_parse_parameters(ZEND_NUM_ARGS() , "Sz|a!", &destination, &msg, &headers) == FAILURE) { + return; +- } ++ } + FETCH_STOMP_OBJECT; + } else { + zval *arg; +@@ -718,7 +718,7 @@ PHP_FUNCTION(stomp_send) + } + + INIT_FRAME(frame, "SEND"); +- ++ + /* Translate a PHP array to a stomp_header array */ + if (NULL != headers) { + FRAME_HEADER_FROM_HASHTABLE(frame.headers, Z_ARRVAL_P(headers)); +@@ -727,7 +727,7 @@ PHP_FUNCTION(stomp_send) + /* Add the destination */ + ZVAL_STR(&rv, zend_string_copy(destination)); + zend_hash_str_add(frame.headers, "destination", sizeof("destination") - 1, &rv); +- ++ + if (Z_TYPE_P(msg) == IS_STRING) { + frame.body = Z_STRVAL_P(msg); + frame.body_length = Z_STRLEN_P(msg); +@@ -770,7 +770,7 @@ PHP_FUNCTION(stomp_subscribe) + stomp_t *stomp = NULL; + zend_string *destination; + zval *headers = NULL, rv; +- stomp_frame_t frame = {0}; ++ stomp_frame_t frame = {0}; + int success = 0; + + if (stomp_object) { +@@ -793,7 +793,7 @@ PHP_FUNCTION(stomp_subscribe) + } + + INIT_FRAME(frame, "SUBSCRIBE"); +- ++ + /* Translate a PHP array to a stomp_header array */ + if (NULL != headers) { + FRAME_HEADER_FROM_HASHTABLE(frame.headers, Z_ARRVAL_P(headers)); +@@ -824,7 +824,7 @@ PHP_FUNCTION(stomp_unsubscribe) + stomp_t *stomp = NULL; + zend_string *destination; + zval *headers = NULL, rv; +- stomp_frame_t frame = {0}; ++ stomp_frame_t frame = {0}; + int success = 0; + + if (stomp_object) { +@@ -847,7 +847,7 @@ PHP_FUNCTION(stomp_unsubscribe) + } + + INIT_FRAME(frame, "UNSUBSCRIBE"); +- ++ + /* Translate a PHP array to a stomp_header array */ + if (NULL != headers) { + FRAME_HEADER_FROM_HASHTABLE(frame.headers, Z_ARRVAL_P(headers)); +@@ -866,9 +866,9 @@ PHP_FUNCTION(stomp_unsubscribe) + } + /* }}} */ + +-/* {{{ proto boolean Stomp::hasFrame() ++/* {{{ proto boolean Stomp::hasFrame() + Indicate whether or not there is a frame ready to read */ +-PHP_FUNCTION(stomp_has_frame) ++PHP_FUNCTION(stomp_has_frame) + { + zval *stomp_object = getThis(); + stomp_t *stomp = NULL; +@@ -886,7 +886,7 @@ PHP_FUNCTION(stomp_has_frame) + } + /* }}} */ + +-/* {{{ proto StompFrame Stomp::readFrame() ++/* {{{ proto StompFrame Stomp::readFrame() + Read the next frame */ + PHP_FUNCTION(stomp_read_frame) + { +@@ -947,7 +947,7 @@ PHP_FUNCTION(stomp_read_frame) + zend_hash_update(Z_ARRVAL(headers), key, val); + } ZEND_HASH_FOREACH_END(); + } +- ++ + if (ce) { + zend_fcall_info fci; + zend_fcall_info_cache fcc; +@@ -1029,14 +1029,14 @@ static void _php_stomp_transaction(INTERNAL_FUNCTION_PARAMETERS, char *cmd, size + zval *stomp_object = getThis(); + stomp_t *stomp = NULL; + zend_string *transaction_id; +- stomp_frame_t frame = {0}; ++ stomp_frame_t frame = {0}; + int success = 0; + zval *headers = NULL, rv; + + if (stomp_object) { + if (zend_parse_parameters(ZEND_NUM_ARGS() , "S|a", &transaction_id, &headers) == FAILURE) { + return; +- } ++ } + FETCH_STOMP_OBJECT; + } else { + zval *arg; +@@ -1091,19 +1091,19 @@ PHP_FUNCTION(stomp_abort) + } + /* }}} */ + +-/* {{{ _php_stomp_acknowledgment ++/* {{{ _php_stomp_acknowledgment + */ + static void _php_stomp_acknowledgment(INTERNAL_FUNCTION_PARAMETERS, char *cmd) { + zval *stomp_object = getThis(); + zval *msg, *headers = NULL; + stomp_t *stomp = NULL; +- stomp_frame_t frame = {0}; ++ stomp_frame_t frame = {0}; + int success = 0; + + if (stomp_object) { + if (zend_parse_parameters(ZEND_NUM_ARGS() , "z|a!", &msg, &headers) == FAILURE) { + return; +- } ++ } + FETCH_STOMP_OBJECT; + } else { + zval *arg; +@@ -1135,7 +1135,7 @@ static void _php_stomp_acknowledgment(INTERNAL_FUNCTION_PARAMETERS, char *cmd) { + CLEAR_FRAME(frame); + RETURN_FALSE; + } +- ++ + if (stomp_send(stomp, &frame ) > 0) { + success = stomp_valid_receipt(stomp, &frame); + } +@@ -1161,7 +1161,7 @@ PHP_FUNCTION(stomp_nack) + } + /* }}} */ + +-/* {{{ proto string Stomp::error() ++/* {{{ proto string Stomp::error() + Get the last error message */ + PHP_FUNCTION(stomp_error) + { +@@ -1205,7 +1205,7 @@ PHP_FUNCTION(stomp_set_read_timeout) + if (zend_parse_parameters(ZEND_NUM_ARGS() , "l|l", &sec, &usec) == FAILURE) { + return; + } +- FETCH_STOMP_OBJECT; ++ FETCH_STOMP_OBJECT; + } else { + zval *arg; + if (zend_parse_parameters(ZEND_NUM_ARGS() , "rl|l", &arg, &sec, &usec) == FAILURE) { +@@ -1219,14 +1219,14 @@ PHP_FUNCTION(stomp_set_read_timeout) + } + /* }}} */ + +-/* {{{ proto array Stomp::getTimeout() ++/* {{{ proto array Stomp::getTimeout() + Get the timeout */ + PHP_FUNCTION(stomp_get_read_timeout) + { + zval *stomp_object = getThis(); + stomp_t *stomp = NULL; + if (stomp_object) { +- FETCH_STOMP_OBJECT; ++ FETCH_STOMP_OBJECT; + } else { + zval *arg; + if (zend_parse_parameters(ZEND_NUM_ARGS() , "r", &arg) == FAILURE) { +@@ -1270,7 +1270,7 @@ PHP_METHOD(stompframe, __construct) + Get error details */ + PHP_METHOD(stompexception, getDetails) + { +- zval *object = getThis(); ++ zval *object = getThis(); + zval rv, *details = zend_read_property(stomp_ce_exception, object, "details", sizeof("details")-1, 1, &rv); + RETURN_STR(zval_get_string(details)); + } +diff --git a/php_stomp.h b/php_stomp.h +index 805b9f6..fdaaa3e 100644 +--- a/php_stomp.h ++++ b/php_stomp.h +@@ -24,7 +24,7 @@ + typedef struct _stomp_object { + stomp_t *stomp; + zend_object std; +-} stomp_object_t; ++} stomp_object_t; + + #define PHP_STOMP_EXTNAME "Stomp" + #define PHP_STOMP_VERSION "2.0.2" +@@ -104,7 +104,7 @@ ZEND_END_MODULE_GLOBALS(stomp) + #define STOMP_G(v) TSRMG(stomp_globals_id, zend_stomp_globals *, v) + #else + #define STOMP_G(v) (stomp_globals.v) +-#endif ++#endif + + #endif /* PHP_STOMP_H */ + +diff --git a/stomp.h b/stomp.h +index 19bd8dd..1a422b7 100644 +--- a/stomp.h ++++ b/stomp.h +@@ -40,7 +40,7 @@ typedef struct _stomp_options { + long read_timeout_usec; + #if HAVE_STOMP_SSL + int use_ssl; +-#endif ++#endif + } stomp_options_t; + + typedef struct _stomp_frame { +@@ -57,7 +57,7 @@ typedef struct _stomp_frame_stack { + } stomp_frame_stack_t; + + typedef struct _stomp { +- php_socket_t fd; ++ php_socket_t fd; + php_sockaddr_storage localaddr; + stomp_options_t options; + char *host; +diff --git a/tests/002-version.phpt b/tests/002-version.phpt +index d3779aa..6e30db1 100644 +--- a/tests/002-version.phpt ++++ b/tests/002-version.phpt +@@ -3,7 +3,7 @@ Test stomp_version() + --SKIPIF-- + + --FILE-- +- + --EXPECTF-- +diff --git a/tests/003-connect/001.phpt b/tests/003-connect/001.phpt +index 31b48c1..1e3c968 100644 +--- a/tests/003-connect/001.phpt ++++ b/tests/003-connect/001.phpt +@@ -3,7 +3,7 @@ Test stomp_connect() - URI validation + --SKIPIF-- + + --FILE-- +- + --FILE-- +- + --FILE-- +- + --FILE-- +- + --FILE-- +- + --EXPECTF-- +diff --git a/tests/005-close/002.phpt b/tests/005-close/002.phpt +index b24c197..b3dbd95 100644 +--- a/tests/005-close/002.phpt ++++ b/tests/005-close/002.phpt +@@ -1,12 +1,12 @@ + --TEST-- + Test stomp_close() + --SKIPIF-- +- + --FILE-- +- + --FILE-- +- + --FILE-- +- + --FILE-- +-send('/queue/test-06', 'A real message', array('receipt' => 'message-12345'))); +diff --git a/tests/007-subscribe/001.phpt b/tests/007-subscribe/001.phpt +index 644c404..8d190dd 100644 +--- a/tests/007-subscribe/001.phpt ++++ b/tests/007-subscribe/001.phpt +@@ -6,7 +6,7 @@ $require_connection = true; + include dirname(__DIR__) . "/skipif.inc"; + ?> + --FILE-- +- + --FILE-- +- + --FILE-- +- + --FILE-- +- + --FILE-- +- + --FILE-- +- + --FILE-- +- + --FILE-- +- +Date: Fri, 25 Sep 2020 16:06:39 +0200 +Subject: [PATCH 1/2] Fix compatibility with PHP 8 - cleanup remaining TSRMLS + macros - fix read/update_property parameters - adapt test suite for exception + in arg. parsing - fix callback + +--- + php_stomp.c | 38 ++++++++++++++++++++-------------- + stomp.c | 6 +++--- + stomp.h | 4 ++-- + tests/003-connect/003.phpt | 2 +- + tests/005-close/001.phpt | 8 +++++-- + tests/007-subscribe/001.phpt | 2 +- + tests/008-unsubscribe/001.phpt | 2 +- + tests/010-timeout/001.phpt | 24 ++++++++++++--------- + tests/010-timeout/002.phpt | 26 ++++++++++++++--------- + 9 files changed, 67 insertions(+), 45 deletions(-) + +diff --git a/php_stomp.c b/php_stomp.c +index 0dcefed..b99a9ff 100644 +--- a/php_stomp.c ++++ b/php_stomp.c +@@ -95,7 +95,7 @@ + zval _object, *object = &_object; \ + THROW_STOMP_EXCEPTION(object, errno, msg) \ + if (details) { \ +- zend_update_property_string(stomp_ce_exception, object, "details", sizeof("details")-1, (char *) details ); \ ++ zend_update_property_string(stomp_ce_exception, OBJ_FOR_PROP(object), "details", sizeof("details")-1, (char *) details ); \ + } \ + } + +@@ -105,6 +105,12 @@ + #define STOMP_URL_STR(a) ZSTR_VAL(a) + #endif + ++#if PHP_VERSION_ID < 80000 ++#define OBJ_FOR_PROP(zv) (zv) ++#else ++#define OBJ_FOR_PROP(zv) Z_OBJ_P(zv) ++#endif ++ + static int le_stomp; + static zend_object_handlers stomp_obj_handlers; + +@@ -562,7 +568,7 @@ PHP_FUNCTION(stomp_connect) + zval excobj; + THROW_STOMP_EXCEPTION(&excobj, stomp->errnum, stomp->error); + if (stomp->error_details) { +- zend_update_property_string(stomp_ce_exception, &excobj, "details", sizeof("details")-1, stomp->error_details ); ++ zend_update_property_string(stomp_ce_exception, OBJ_FOR_PROP(&excobj), "details", sizeof("details")-1, stomp->error_details ); + } + return; + } +@@ -576,7 +582,7 @@ PHP_FUNCTION(stomp_connect) + if ((error_msg = zend_hash_str_find(res->headers, ZEND_STRL("message"))) != NULL) { + THROW_STOMP_EXCEPTION(&excobj, 0, ZSTR_VAL(Z_STR_P(error_msg))); + if (res->body) { +- zend_update_property_string(stomp_ce_exception, &excobj, "details", sizeof("details")-1, (char *) res->body ); ++ zend_update_property_string(stomp_ce_exception, OBJ_FOR_PROP(&excobj), "details", sizeof("details")-1, (char *) res->body ); + } + } + stomp_free_frame(res); +@@ -733,17 +739,17 @@ PHP_FUNCTION(stomp_send) + frame.body_length = Z_STRLEN_P(msg); + } else if (Z_TYPE_P(msg) == IS_OBJECT && instanceof_function(Z_OBJCE_P(msg), stomp_ce_frame )) { + zval *frame_obj_prop = NULL; +- frame_obj_prop = zend_read_property(stomp_ce_frame, msg, "command", sizeof("command")-1, 1, &rv); ++ frame_obj_prop = zend_read_property(stomp_ce_frame, OBJ_FOR_PROP(msg), "command", sizeof("command")-1, 1, &rv); + if (Z_TYPE_P(frame_obj_prop) == IS_STRING) { + frame.command = Z_STRVAL_P(frame_obj_prop); + frame.command_length = Z_STRLEN_P(frame_obj_prop); + } +- frame_obj_prop = zend_read_property(stomp_ce_frame, msg, "body", sizeof("body")-1, 1, &rv); ++ frame_obj_prop = zend_read_property(stomp_ce_frame, OBJ_FOR_PROP(msg), "body", sizeof("body")-1, 1, &rv); + if (Z_TYPE_P(frame_obj_prop) == IS_STRING) { + frame.body = Z_STRVAL_P(frame_obj_prop); + frame.body_length = Z_STRLEN_P(frame_obj_prop); + } +- frame_obj_prop = zend_read_property(stomp_ce_frame, msg, "headers", sizeof("headers")-1, 1, &rv); ++ frame_obj_prop = zend_read_property(stomp_ce_frame, OBJ_FOR_PROP(msg), "headers", sizeof("headers")-1, 1, &rv); + if (Z_TYPE_P(frame_obj_prop) == IS_ARRAY) { + FRAME_HEADER_FROM_HASHTABLE(frame.headers, Z_ARRVAL_P(frame_obj_prop)); + } +@@ -928,7 +934,7 @@ PHP_FUNCTION(stomp_read_frame) + zval excobj; + THROW_STOMP_EXCEPTION(&excobj, 0, Z_STRVAL_P(error_msg)); + if (res->body) { +- zend_update_property_string(stomp_ce_exception, &excobj, ZEND_STRL("details"), (char *)res->body ); ++ zend_update_property_string(stomp_ce_exception, OBJ_FOR_PROP(&excobj), ZEND_STRL("details"), (char *)res->body ); + } + stomp_free_frame(res); + RETURN_FALSE; +@@ -966,10 +972,11 @@ PHP_FUNCTION(stomp_read_frame) + ZVAL_NULL(&body); + } + ++ memset(&fci, 0, sizeof(fci)); ++ memset(&fcc, 0, sizeof(fcc)); + fci.size = sizeof(fci); + #if (PHP_MAJOR_VERSION == 7 && PHP_MINOR_VERSION == 0) + fci.function_table = &ce->function_table; +- fci.symbol_table = NULL; + #endif + /* PARAMS */ + fci.param_count = 3; +@@ -981,8 +988,9 @@ PHP_FUNCTION(stomp_read_frame) + ZVAL_UNDEF(&fci.function_name); + fci.object = Z_OBJ_P(return_value); + fci.retval = &retval; ++#if PHP_VERSION_ID < 80000 + fci.no_separation = 1; +- ++#endif + #if PHP_VERSION_ID < 70300 + fcc.initialized = 1; + #endif +@@ -995,7 +1003,7 @@ PHP_FUNCTION(stomp_read_frame) + fcc.object = Z_OBJ_P(return_value); + + if (zend_call_function(&fci, &fcc ) == FAILURE) { +- 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)); ++ 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)); + } else { + zval_ptr_dtor(&retval); + } +@@ -1125,7 +1133,7 @@ static void _php_stomp_acknowledgment(INTERNAL_FUNCTION_PARAMETERS, char *cmd) { + } else if (Z_TYPE_P(msg) == IS_OBJECT && instanceof_function(Z_OBJCE_P(msg), stomp_ce_frame )) { + zval *frame_obj_prop, rv; + +- frame_obj_prop = zend_read_property(stomp_ce_frame, msg, "headers", sizeof("headers")-1, 1, &rv); ++ frame_obj_prop = zend_read_property(stomp_ce_frame, OBJ_FOR_PROP(msg), "headers", sizeof("headers")-1, 1, &rv); + if (Z_TYPE_P(frame_obj_prop) == IS_ARRAY) { + FRAME_HEADER_FROM_HASHTABLE(frame.headers, Z_ARRVAL_P(frame_obj_prop)); + } +@@ -1255,13 +1263,13 @@ PHP_METHOD(stompframe, __construct) + } + + if (command_length > 0) { +- zend_update_property_stringl(stomp_ce_frame, object, "command", sizeof("command")-1, command, command_length ); ++ zend_update_property_stringl(stomp_ce_frame, OBJ_FOR_PROP(object), "command", sizeof("command")-1, command, command_length ); + } + if (headers) { +- zend_update_property(stomp_ce_frame, object, "headers", sizeof("headers")-1, headers ); ++ zend_update_property(stomp_ce_frame, OBJ_FOR_PROP(object), "headers", sizeof("headers")-1, headers ); + } + if (body_length > 0) { +- zend_update_property_stringl(stomp_ce_frame, object, "body", sizeof("body")-1, body, body_length ); ++ zend_update_property_stringl(stomp_ce_frame, OBJ_FOR_PROP(object), "body", sizeof("body")-1, body, body_length ); + } + } + /* }}} */ +@@ -1271,7 +1279,7 @@ PHP_METHOD(stompframe, __construct) + PHP_METHOD(stompexception, getDetails) + { + zval *object = getThis(); +- zval rv, *details = zend_read_property(stomp_ce_exception, object, "details", sizeof("details")-1, 1, &rv); ++ zval rv, *details = zend_read_property(stomp_ce_exception, OBJ_FOR_PROP(object), "details", sizeof("details")-1, 1, &rv); + RETURN_STR(zval_get_string(details)); + } + /* }}} */ +diff --git a/stomp.c b/stomp.c +index d83a4e6..6e77ede 100644 +--- a/stomp.c ++++ b/stomp.c +@@ -34,7 +34,7 @@ extern zend_class_entry *stomp_ce_exception; + + /* {{{ DEBUG */ + #if PHP_DEBUG +-static void print_stomp_frame(stomp_frame_t *frame TSRMLS_DC) { ++static void print_stomp_frame(stomp_frame_t *frame) { + php_printf("------ START FRAME ------\n"); + php_printf("%s\n", frame->command); + /* Headers */ +@@ -186,7 +186,7 @@ int stomp_writable(stomp_t *stomp) + + /* {{{ stomp_connect + */ +-int stomp_connect(stomp_t *stomp, const char *host, unsigned short port TSRMLS_DC) ++int stomp_connect(stomp_t *stomp, const char *host, unsigned short port) + { + char error[1024]; + socklen_t size; +@@ -297,7 +297,7 @@ void stomp_close(stomp_t *stomp) + + /* {{{ stomp_send + */ +-int stomp_send(stomp_t *stomp, stomp_frame_t *frame TSRMLS_DC) ++int stomp_send(stomp_t *stomp, stomp_frame_t *frame) + { + smart_str buf = {0}; + +diff --git a/stomp.h b/stomp.h +index 1a422b7..e4d02b3 100644 +--- a/stomp.h ++++ b/stomp.h +@@ -79,9 +79,9 @@ typedef struct _stomp { + } stomp_t; + + stomp_t *stomp_init(); +-int stomp_connect(stomp_t *stomp, const char *host, unsigned short port TSRMLS_DC); ++int stomp_connect(stomp_t *stomp, const char *host, unsigned short port); + void stomp_close(stomp_t *stomp); +-int stomp_send(stomp_t *connection, stomp_frame_t *frame TSRMLS_DC); ++int stomp_send(stomp_t *connection, stomp_frame_t *frame); + stomp_frame_t *stomp_read_frame_ex(stomp_t *connection, int use_stack); + int stomp_valid_receipt(stomp_t *connection, stomp_frame_t *frame); + int stomp_select_ex(stomp_t *connection, const long int sec, const long int usec); +diff --git a/tests/003-connect/003.phpt b/tests/003-connect/003.phpt +index b3de8d6..ba60e15 100644 +--- a/tests/003-connect/003.phpt ++++ b/tests/003-connect/003.phpt +@@ -2,7 +2,7 @@ + Test stomp_connect() - Test error on CONNECT + --SKIPIF-- + + --FILE-- + + --FILE-- + getMessage() . PHP_EOL; ++} + ?> + --EXPECTF-- +-Warning: stomp_close() expects parameter 1 to be resource, null given in %s on line %d ++%stomp_close()%s1%s null %s +diff --git a/tests/007-subscribe/001.phpt b/tests/007-subscribe/001.phpt +index 8d190dd..494471c 100644 +--- a/tests/007-subscribe/001.phpt ++++ b/tests/007-subscribe/001.phpt +@@ -16,7 +16,7 @@ $s->subscribe('/queue/test', 'string'); + --EXPECTF-- + Warning: Stomp::subscribe(): Destination can not be empty in %s007-subscribe%c001.php on line %d + +-Fatal error: Uncaught TypeError: Argument 2 passed to Stomp::subscribe() must be of the type array, string given in %s007-subscribe%c001.php:%d ++Fatal error: Uncaught TypeError: %s, string given in %s007-subscribe%c001.php:%d + Stack trace: + #0 %s001.php(%d): Stomp->subscribe('/queue/test', 'string') + #1 {main} +diff --git a/tests/008-unsubscribe/001.phpt b/tests/008-unsubscribe/001.phpt +index c1200eb..7d1b50f 100644 +--- a/tests/008-unsubscribe/001.phpt ++++ b/tests/008-unsubscribe/001.phpt +@@ -17,7 +17,7 @@ $s->unsubscribe('/queue/test', 'string'); + --EXPECTF-- + Warning: Stomp::unsubscribe(): Destination can not be empty in %s008-unsubscribe%c001.php on line %d + +-Fatal error: Uncaught TypeError: Argument 2 passed to Stomp::unsubscribe() must be of the type array, string given in %s008-unsubscribe%c001.php:%d ++Fatal error: Uncaught TypeError: %s2%s string given in %s008-unsubscribe%c001.php:%d + Stack trace: + #0 %s(%d): Stomp->unsubscribe('/queue/test', 'string') + #1 {main} +diff --git a/tests/010-timeout/001.phpt b/tests/010-timeout/001.phpt +index 7389f70..b9886db 100644 +--- a/tests/010-timeout/001.phpt ++++ b/tests/010-timeout/001.phpt +@@ -25,13 +25,21 @@ var_dump($s->setReadTimeout(10, 5)); + // Third test, read supposed to return 10.5 + var_dump($s->getReadTimeout()); + +-// Set read timout with the first param as a string, supposed to trigger a warning +-var_dump($s->setReadTimeout('')); ++try { ++ // Set read timout with the first param as a string, supposed to trigger a warning/exception ++ var_dump($s->setReadTimeout('')); ++} catch (TypeError $e) { ++ echo $e->getMessage() . PHP_EOL; ++} + // Fourth test, read supposed to get the last value set : 10.5 + var_dump($s->getReadTimeout()); + +-// Set read timout with the second param as a string, supposed to trigger a warning +-var_dump($s->setReadTimeout(10, '')); ++try { ++ // Set read timout with the second param as a string, supposed to trigger a warning/exception ++ var_dump($s->setReadTimeout(10, '')); ++} catch (TypeError $e) { ++ echo $e->getMessage() . PHP_EOL; ++} + // Fourth test, read supposed to get the last value set : 10.5 + var_dump($s->getReadTimeout()); + +@@ -64,18 +72,14 @@ array(2) { + ["usec"]=> + int(5) + } +- +-Warning: Stomp::setReadTimeout() expects parameter 1 to be long, string given in %s on line %d +-NULL ++%AStomp::setReadTimeout()%s1%s string given%A + array(2) { + ["sec"]=> + int(10) + ["usec"]=> + int(5) + } +- +-Warning: Stomp::setReadTimeout() expects parameter 2 to be long, string given in %s on line %d +-NULL ++%AStomp::setReadTimeout()%s2%s string given%A + array(2) { + ["sec"]=> + int(10) +diff --git a/tests/010-timeout/002.phpt b/tests/010-timeout/002.phpt +index a6a9b4a..c22dedf 100644 +--- a/tests/010-timeout/002.phpt ++++ b/tests/010-timeout/002.phpt +@@ -25,13 +25,23 @@ var_dump(stomp_set_read_timeout($link, 10, 5)); + // Third test, read supposed to return 10.5 + var_dump(stomp_get_read_timeout($link)); + +-// Set read timout with the first param as a string, supposed to trigger a warning +-var_dump(stomp_set_read_timeout($link, '')); ++try { ++ // Set read timout with the first param as a string, supposed to trigger a warning on PHP 7 ++ // supposed to trigger an exception on PHP 8 ++ var_dump(stomp_set_read_timeout($link, '')); ++} catch (TypeError $e) { ++ echo $e->getMessage() . PHP_EOL; ++} + // Fourth test, read supposed to get the last value set : 10.5 + var_dump(stomp_get_read_timeout($link)); + +-// Set read timout with the second param as a string, supposed to trigger a warning +-var_dump(stomp_set_read_timeout($link, 10, '')); ++try { ++ // Set read timout with the second param as a string, supposed to trigger a warning on PHP 7 ++ // supposed to trigger an exception on PHP 8 ++ var_dump(stomp_set_read_timeout($link, 10, '')); ++} catch (TypeError $e) { ++ echo $e->getMessage() . PHP_EOL; ++} + // Fourth test, read supposed to get the last value set : 10.5 + var_dump(stomp_get_read_timeout($link)); + +@@ -64,18 +74,14 @@ array(2) { + ["usec"]=> + int(5) + } +- +-Warning: stomp_set_read_timeout() expects parameter 2 to be long, string given in %s on line %d +-NULL ++%Astomp_set_read_timeout()%s2%S string given%A + array(2) { + ["sec"]=> + int(10) + ["usec"]=> + int(5) + } +- +-Warning: stomp_set_read_timeout() expects parameter 3 to be long, string given in %s on line %d +-NULL ++%Astomp_set_read_timeout()%s3%s string given%A + array(2) { + ["sec"]=> + int(10) + +From 5e438eaa570cf73c323026da58ddeae13a9daacf Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Mon, 27 Sep 2021 15:40:19 +0200 +Subject: [PATCH] allow NULL for transaction_id + +--- + php_stomp.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/php_stomp.c b/php_stomp.c +index b99a9ff..8e96b20 100644 +--- a/php_stomp.c ++++ b/php_stomp.c +@@ -1042,13 +1042,13 @@ static void _php_stomp_transaction(INTERNAL_FUNCTION_PARAMETERS, char *cmd, size + zval *headers = NULL, rv; + + if (stomp_object) { +- if (zend_parse_parameters(ZEND_NUM_ARGS() , "S|a", &transaction_id, &headers) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS() , "S!|a", &transaction_id, &headers) == FAILURE) { + return; + } + FETCH_STOMP_OBJECT; + } else { + zval *arg; +- if (zend_parse_parameters(ZEND_NUM_ARGS() , "rS|a", &arg, &transaction_id, &headers) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS() , "rS!|a", &arg, &transaction_id, &headers) == FAILURE) { + return; + } + FETCH_STOMP_RSRC(stomp, arg); +@@ -1056,7 +1056,7 @@ static void _php_stomp_transaction(INTERNAL_FUNCTION_PARAMETERS, char *cmd, size + + INIT_FRAME_L(frame, cmd, cmd_len); + +- if (ZSTR_LEN(transaction_id)) { ++ if (transaction_id && ZSTR_LEN(transaction_id)) { + ZVAL_STR(&rv, zend_string_copy(transaction_id)); + zend_hash_str_add(frame.headers, "transaction", sizeof("transaction") - 1, &rv); + } +From 8c96bd7d77b0dd375d0a644f0847d6ca6270adf9 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Mon, 27 Sep 2021 15:40:49 +0200 +Subject: [PATCH] don't use NULL for integer + +--- + tests/010-timeout/001.phpt | 2 +- + tests/010-timeout/002.phpt | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/tests/010-timeout/001.phpt b/tests/010-timeout/001.phpt +index b9886db..15fe931 100644 +--- a/tests/010-timeout/001.phpt ++++ b/tests/010-timeout/001.phpt +@@ -44,7 +44,7 @@ try { + var_dump($s->getReadTimeout()); + + // Set read timout with the params as null +-var_dump($s->setReadTimeout(null, null)); ++var_dump($s->setReadTimeout(0, 0)); + // Fifth test, read supposed to get the last value set : 0.0 + var_dump($s->getReadTimeout()); + +diff --git a/tests/010-timeout/002.phpt b/tests/010-timeout/002.phpt +index c22dedf..b7da6c7 100644 +--- a/tests/010-timeout/002.phpt ++++ b/tests/010-timeout/002.phpt +@@ -46,7 +46,7 @@ try { + var_dump(stomp_get_read_timeout($link)); + + // Set read timout with the params as null +-var_dump(stomp_set_read_timeout($link, null, null)); ++var_dump(stomp_set_read_timeout($link, 0, 0)); + // Fifth test, read supposed to get the last value set : 0.0 + var_dump(stomp_get_read_timeout($link)); + +From 380e82bba1567bac80264b212bbb9df040b48a56 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Mon, 27 Sep 2021 16:01:59 +0200 +Subject: [PATCH] only add the ack if not already in the headers + +--- + php_stomp.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +diff --git a/php_stomp.c b/php_stomp.c +index 8e96b20..11cf006 100644 +--- a/php_stomp.c ++++ b/php_stomp.c +@@ -805,10 +805,13 @@ PHP_FUNCTION(stomp_subscribe) + FRAME_HEADER_FROM_HASHTABLE(frame.headers, Z_ARRVAL_P(headers)); + } + +- /* Add the destination */ +- ZVAL_STRINGL(&rv, "client", sizeof("client") - 1); +- zend_hash_str_update(frame.headers, "ack", sizeof("ack") - 1, &rv); ++ /* Add the ack if not already in the headers */ ++ if (!zend_hash_str_find(frame.headers, ZEND_STRL("ack"))) { ++ ZVAL_STRINGL(&rv, "client", sizeof("client") - 1); ++ zend_hash_str_update(frame.headers, "ack", sizeof("ack") - 1, &rv); ++ } + ++ /* Add the destination */ + ZVAL_STR(&rv, zend_string_copy(destination)); + zend_hash_str_update(frame.headers, "destination", sizeof("destination") - 1, &rv); + /* zend_hash_str_add_ptr(frame.headers, ZEND_STRL("activemq.prefetchSize"), estrdup("1")); */ -- cgit