diff options
-rw-r--r-- | php-pecl-rdkafka6.spec | 13 | ||||
-rw-r--r-- | upstream.patch | 85 |
2 files changed, 95 insertions, 3 deletions
diff --git a/php-pecl-rdkafka6.spec b/php-pecl-rdkafka6.spec index 834acf0..59440d1 100644 --- a/php-pecl-rdkafka6.spec +++ b/php-pecl-rdkafka6.spec @@ -39,11 +39,14 @@ Summary: Kafka client based on librdkafka Name: %{?scl_prefix}php-pecl-%{pecl_name}6 Version: %{upstream_version}%{?upstream_prever:~%{upstream_prever}} -Release: 1%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} +Release: 2%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} License: MIT URL: https://pecl.php.net/package/%{pecl_name} Source0: https://pecl.php.net/get/%{pecl_name}-%{upstream_version}%{?upstream_prever}.tgz +# See https://github.com/arnaud-lb/php-rdkafka/issues/562 +Patch0: upstream.patch + BuildRequires: make BuildRequires: %{?dtsprefix}gcc %if %{with move_to_opt} @@ -52,8 +55,7 @@ Requires: %{?vendeur:%{vendeur}-}librdkafka%{?_isa} >= %{buildver} %else BuildRequires: librdkafka-devel >= 1.4 %endif -# See https://github.com/arnaud-lb/php-rdkafka/issues/562 -BuildRequires: %{?scl_prefix}php-devel >= 7.3 +BuildRequires: %{?scl_prefix}php-devel >= 7.0 BuildRequires: %{?scl_prefix}php-pear Requires: %{?scl_prefix}php(zend-abi) = %{php_zend_api} @@ -99,6 +101,8 @@ sed -e 's/role="test"/role="src"/' \ -i package.xml cd %{sources} +%patch -P0 -p1 -b .up + # Sanity check, really often broken extver=$(sed -n '/#define PHP_RDKAFKA_VERSION/{s/.* "//;s/".*$//;p}' php_rdkafka.h) if test "x${extver}" != "x%{upstream_version}%{?upstream_prever}"; then @@ -220,6 +224,9 @@ REPORT_EXIT_STATUS=1 \ %changelog +* Fri Oct 25 2024 Remi Collet <remi@remirepo.net> - 6.0.4-2 +- add upstream patch for old PHP versions + * Fri Oct 25 2024 Remi Collet <remi@remirepo.net> - 6.0.4-1 - update to 6.0.4 - open https://github.com/arnaud-lb/php-rdkafka/issues/562 diff --git a/upstream.patch b/upstream.patch new file mode 100644 index 0000000..fda3ecf --- /dev/null +++ b/upstream.patch @@ -0,0 +1,85 @@ +From 6c1a72c93812bf53515ff9293e3ab4849c09b282 Mon Sep 17 00:00:00 2001 +From: Arnaud Le Blanc <arnaud.lb@gmail.com> +Date: Fri, 25 Oct 2024 13:59:21 +0200 +Subject: [PATCH] Fix build on php 7.0 (#563) + +Co-authored-by: Remi Collet <remi@remirepo.net> +--- + kafka_error_exception.c | 6 +++--- + php_rdkafka_priv.h | 16 +++++++++++++++- + rdkafka.c | 4 +--- + tests/oauthbearer_integration.phpt | 2 +- + 4 files changed, 20 insertions(+), 8 deletions(-) + +diff --git a/kafka_error_exception.c b/kafka_error_exception.c +index 8c19ca0c..f28730fd 100644 +--- a/kafka_error_exception.c ++++ b/kafka_error_exception.c +@@ -39,9 +39,9 @@ void create_kafka_error(zval *return_value, const rd_kafka_error_t *error) /* {{ + { + object_init_ex(return_value, ce_kafka_error); + +- zend_string *message = zend_strpprintf(0, "%s (RD_KAFKA_RESP_ERR_%s)", rd_kafka_error_string(error), rd_kafka_error_name(error)); +- zend_update_property_str(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("message"), message); +- zend_string_release(message); ++ char message[1024]; ++ snprintf(message, sizeof(message), "%s (RD_KAFKA_RESP_ERR_%s)", rd_kafka_error_string(error), rd_kafka_error_name(error)); ++ zend_update_property_string(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("message"), message); + + zend_update_property_long(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("code"), rd_kafka_error_code(error)); + zend_update_property_string(ce_kafka_error, Z_RDKAFKA_PROP_OBJ(return_value), ZEND_STRL("error_string"), rd_kafka_error_string(error)); +diff --git a/php_rdkafka_priv.h b/php_rdkafka_priv.h +index 695a2739..ee6b440e 100644 +--- a/php_rdkafka_priv.h ++++ b/php_rdkafka_priv.h +@@ -79,7 +79,21 @@ static zend_always_inline void *zend_object_alloc(size_t obj_size, zend_class_en + memset(obj, 0, obj_size - sizeof(zval)); + return obj; + } +-#endif ++ ++static zend_always_inline zend_string *zval_get_tmp_string(zval *op, zend_string **tmp) { ++ if (EXPECTED(Z_TYPE_P(op) == IS_STRING)) { ++ *tmp = NULL; ++ return Z_STR_P(op); ++ } else { ++ return *tmp = _zval_get_string_func(op); ++ } ++} ++static zend_always_inline void zend_tmp_string_release(zend_string *tmp) { ++ if (UNEXPECTED(tmp)) { ++ zend_string_release(tmp); ++ } ++} ++#endif // PHP_MINOR_VERSION < 3 + + #endif // PHP 7 + +diff --git a/rdkafka.c b/rdkafka.c +index 4029409a..727fc8c6 100644 +--- a/rdkafka.c ++++ b/rdkafka.c +@@ -491,9 +491,7 @@ PHP_METHOD(RdKafka, oauthbearerSetToken) + zend_string *tmp_extension_val_str; + zend_string *extension_val_str = zval_get_tmp_string(extension_zval, &tmp_extension_val_str); + extensions[pos++] = estrdup(ZSTR_VAL(extension_val_str)); +- if (tmp_extension_val_str) { +- zend_string_release(tmp_extension_val_str); +- } ++ zend_tmp_string_release(tmp_extension_val_str); + } ZEND_HASH_FOREACH_END(); + } + +diff --git a/tests/oauthbearer_integration.phpt b/tests/oauthbearer_integration.phpt +index b95de0f6..1b9399cb 100644 +--- a/tests/oauthbearer_integration.phpt ++++ b/tests/oauthbearer_integration.phpt +@@ -20,7 +20,7 @@ function generateJws($scope = 'required-scope', $expiresInSeconds = 60) + $principal, + $expirySeconds, + $nowSeconds - 10, +- $scope, ++ $scope + ); + $headerJwsSegment = 'eyJhbGciOiJub25lIn0'; + $claimsJwsSegment = base64_encode($claimsJson); |