From ef541033e21af1431416a784048cee9cd225da64 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 11 Jul 2024 09:42:25 +0200 Subject: use valkey on Fedora 41 add upstream patch for PHP 8.4 --- php-pecl-redis6.spec | 41 ++++++++++++++---- redis-upstream.patch | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 149 insertions(+), 8 deletions(-) create mode 100644 redis-upstream.patch diff --git a/php-pecl-redis6.spec b/php-pecl-redis6.spec index 6544232..2445aaa 100644 --- a/php-pecl-redis6.spec +++ b/php-pecl-redis6.spec @@ -3,7 +3,7 @@ # # remirepo spec file for php-pecl-redis6 # -# Copyright (c) 2012-2023 Remi Collet +# Copyright (c) 2012-2024 Remi Collet # License: CC-BY-SA-4.0 # http://creativecommons.org/licenses/by-sa/4.0/ # @@ -13,6 +13,11 @@ %bcond_without tests %bcond_without igbinary %bcond_without msgpack +%if 0%{?fedora} >= 41 || 0%{?rhel} >= 10 +%bcond_without valkey +%else +%bcond_with valkey +%endif %global pecl_name redis %global with_zts 0%{!?_without_zts:%{?__ztsphp:1}} @@ -27,11 +32,13 @@ Summary: Extension for communicating with the Redis key-value store Name: php-pecl-redis6 Version: %{upstream_version}%{?upstream_prever:~%{upstream_prever}} -Release: 1%{?dist} +Release: 2%{?dist} License: PHP-3.01 URL: https://pecl.php.net/package/redis Source0: https://pecl.php.net/get/%{sources}.tgz +Patch0: %{pecl_name}-upstream.patch + ExcludeArch: %{ix86} BuildRequires: make @@ -50,8 +57,12 @@ BuildRequires: pkgconfig(libzstd) >= 1.3.0 BuildRequires: pkgconfig(liblz4) # to run Test suite %if %{with tests} +%if %{with valkey} +BuildRequires: valkey >= 7 +%else BuildRequires: redis >= 7 %endif +%endif Requires: php(zend-abi) = %{php_zend_api} Requires: php(api) = %{php_core_api} @@ -68,7 +79,7 @@ Provides: php-%{pecl_name}%{?_isa} = %{version} Provides: php-pecl(%{pecl_name}) = %{version} Provides: php-pecl(%{pecl_name})%{?_isa} = %{version} -%if 0%{?fedora} >= 40 || 0%{?rhel} >= 10 || "%{php_version}" > "8.3" +%if 0%{?fedora} >= 41 || 0%{?rhel} >= 10 || "%{php_version}" > "8.4" Obsoletes: php-pecl-%{pecl_name} < 6 Provides: php-pecl-%{pecl_name} = %{version}-%{release} Provides: php-pecl-%{pecl_name}%{?_isa} = %{version}-%{release} @@ -105,6 +116,8 @@ sed -e 's/role="test"/role="src"/' \ -i package.xml cd %{sources} +%patch -P0 -p1 + # Use system library rm -r liblzf @@ -248,14 +261,22 @@ done cd %{sources}/tests : Launch redis server +%if %{with valkey} +SRV=%{_bindir}/valkey-server +CLI=%{_bindir}/valkey-cli +%else +SRV=%{_bindir}/redis-server +CLI=%{_bindir}/redis-cli +%endif + mkdir -p data -pidfile=$PWD/redis.pid +pidfile=$PWD/server.pid port=$(%{__php} -r 'echo 9000 + PHP_MAJOR_VERSION*100 + PHP_MINOR_VERSION*10 + PHP_INT_SIZE;') -%{_bindir}/redis-server \ +$SRV \ --bind 127.0.0.1 \ --port $port \ --daemonize yes \ - --logfile $PWD/redis.log \ + --logfile $PWD/server.log \ --dir $PWD/data \ --pidfile $pidfile @@ -271,10 +292,10 @@ $TEST_PHP_EXECUTABLE $TEST_PHP_ARGS TestRedis.php || ret=1 : Cleanup if [ -f $pidfile ]; then - %{_bindir}/redis-cli -p $port shutdown nosave + $CLI -p $port shutdown nosave sleep 2 fi -cat $PWD/redis.log +cat $PWD/server.log exit $ret %else @@ -296,6 +317,10 @@ exit $ret %changelog +* Thu Jul 11 2024 Remi Collet - 6.0.2-2 +- use valkey on Fedora 41 +- add upstream patch for PHP 8.4 + * Mon Oct 23 2023 Remi Collet - 6.0.2-1 - update to 6.0.2 diff --git a/redis-upstream.patch b/redis-upstream.patch new file mode 100644 index 0000000..03bd34f --- /dev/null +++ b/redis-upstream.patch @@ -0,0 +1,116 @@ +From a51215ce2b22bcd1f506780c35b6833471e0b8cb Mon Sep 17 00:00:00 2001 +From: michael-grunder +Date: Mon, 18 Mar 2024 14:42:35 -0700 +Subject: [PATCH] Update random includes. + +PHP 8.4 has some breaking changes with respect to where PHP's random methods and +helpers are. This commit fixes those issues while staying backward compatible. + +Fixes #2463 +--- + backoff.c | 12 ++++++------ + library.c | 7 ++++++- + redis.c | 6 +++++- + 3 files changed, 17 insertions(+), 8 deletions(-) + +diff --git a/backoff.c b/backoff.c +index d0961fcfaf..1be04a8fe8 100644 +--- a/backoff.c ++++ b/backoff.c +@@ -1,14 +1,14 @@ + #include "common.h" + ++#if PHP_VERSION_ID < 80400 + #include +- +-#if PHP_VERSION_ID >= 70100 +-#include + #else ++#include ++#endif ++ ++#if PHP_VERSION_ID < 70100 + static zend_long php_mt_rand_range(zend_long min, zend_long max) { +- zend_long number = php_rand(); +- RAND_RANGE(number, min, max, PHP_RAND_MAX); +- return number; ++ return min + php_rand() % (max - min + 1) + } + #endif + +diff --git a/library.c b/library.c +index 3d65c8529d..f81556a9ed 100644 +--- a/library.c ++++ b/library.c +@@ -56,9 +56,14 @@ + #include + #endif + +-#include + #include + ++#if PHP_VERSION_ID < 80400 ++#include ++#else ++#include ++#endif ++ + #define UNSERIALIZE_NONE 0 + #define UNSERIALIZE_KEYS 1 + #define UNSERIALIZE_VALS 2 +diff --git a/redis.c b/redis.c +index ec6f65d2ed..2330bf7edf 100644 +--- a/redis.c ++++ b/redis.c +@@ -27,12 +27,16 @@ + #include "redis_cluster.h" + #include "redis_commands.h" + #include "redis_sentinel.h" +-#include + #include + #include + #include + #include + ++#if PHP_VERSION_ID < 80400 ++#include ++#else ++#include ++#endif + + #ifdef PHP_SESSION + #include +From c139de3abac1dd33b97ef0de5af41b6e3a78f7ab Mon Sep 17 00:00:00 2001 +From: michael-grunder +Date: Sat, 1 Jun 2024 13:09:30 -0700 +Subject: [PATCH] We don't need to use a ranom value for our ECHO liveness + challenge. + +A microsecond resolution timestamp combined with a monotonically +incremented counter should be sufficient. + +This also fixes PHP 8.4 compilation as PHP 8.4 doesn't seem to have +`php_rand()`. +--- + library.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/library.c b/library.c +index ce0cbda26..42a132c4c 100644 +--- a/library.c ++++ b/library.c +@@ -2886,11 +2886,13 @@ redis_sock_create(char *host, int host_len, int port, + } + + static int redis_uniqid(char *buf, size_t buflen) { ++ static unsigned long counter = 0; + struct timeval tv; ++ + gettimeofday(&tv, NULL); + + return snprintf(buf, buflen, "phpredis:%08lx%05lx:%08lx", +- (long)tv.tv_sec, (long)tv.tv_usec, (long)php_rand()); ++ (long)tv.tv_sec, (long)tv.tv_usec, counter++); + } + + static int redis_stream_liveness_check(php_stream *stream) { -- cgit