summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--REFLECTION2
-rw-r--r--php-pecl-redis6.spec38
-rw-r--r--redis-8.0.patch122
3 files changed, 143 insertions, 19 deletions
diff --git a/REFLECTION b/REFLECTION
index 4e03f0e..0f3b648 100644
--- a/REFLECTION
+++ b/REFLECTION
@@ -1,4 +1,4 @@
-Extension [ <persistent> extension #131 redis version 6.2.0 ] {
+Extension [ <persistent> extension #136 redis version 6.2.0 ] {
- Dependencies {
Dependency [ igbinary (Required) ]
diff --git a/php-pecl-redis6.spec b/php-pecl-redis6.spec
index 198cc05..5de3bc6 100644
--- a/php-pecl-redis6.spec
+++ b/php-pecl-redis6.spec
@@ -16,13 +16,9 @@
%endif
%bcond_without igbinary
%bcond_without msgpack
-%if 0%{?fedora} >= 41 || 0%{?rhel} >= 10
-%bcond_without valkey
-%else
-# Use valkey instead of redis for tests
-%bcond_with valkey
-%endif
-# Use keydb instead of redis for tests
+# use redis instead of valkey for tests
+%bcond_with redis
+# Use keydb instead of valkey for tests
%bcond_with keydb
%global pie_vend phpredis
@@ -40,11 +36,13 @@
Summary: PHP extension for interfacing with key-value stores
Name: %{?scl_prefix}php-pecl-redis6
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: PHP-3.01
URL: https://pecl.php.net/package/redis
Source0: https://pecl.php.net/get/%{sources}.tgz
+Patch0: redis-8.0.patch
+
BuildRequires: make
BuildRequires: %{?dtsprefix}gcc
BuildRequires: %{?scl_prefix}php-devel >= 7.4
@@ -61,13 +59,13 @@ BuildRequires: pkgconfig(libzstd) >= 1.3.0
BuildRequires: pkgconfig(liblz4)
# to run Test suite
%if %{with tests}
-%if %{with valkey}
-BuildRequires: valkey
+%if %{with redis}
+BuildRequires: redis
%else
%if %{with keydb}
BuildRequires: keydb
%else
-BuildRequires: redis
+BuildRequires: valkey
%endif
%endif
%endif
@@ -129,6 +127,8 @@ sed -e 's/role="test"/role="src"/' \
-i package.xml
cd %{sources}
+%patch -P0 -p1
+
# Use system library
rm -r liblzf
@@ -278,18 +278,16 @@ done
%if %{with tests}
cd %{sources}/tests
-: Launch redis server
-%if %{with valkey}
+: Launch the server
SRV=%{_root_bindir}/valkey-server
CLI=%{_root_bindir}/valkey-cli
-%else
-%if %{with keydb}
-SRV=%{_root_bindir}/keydb-server
-CLI=%{_root_bindir}/keydb-cli
-%else
+%if %{with redis}
SRV=%{_root_bindir}/redis-server
CLI=%{_root_bindir}/redis-cli
%endif
+%if %{with keydb}
+SRV=%{_root_bindir}/keydb-server
+CLI=%{_root_bindir}/keydb-cli
%endif
mkdir -p data
@@ -341,6 +339,10 @@ exit $ret
%changelog
+* Tue Jun 24 2025 Remi Collet <remi@remirepo.net> - 6.2.0-2
+- add upstream patch for redis 8
+- use valkey by default for tests
+
* Tue Mar 25 2025 Remi Collet <remi@remirepo.net> - 6.2.0-1
- update to 6.2.0
diff --git a/redis-8.0.patch b/redis-8.0.patch
new file mode 100644
index 0000000..fd713c5
--- /dev/null
+++ b/redis-8.0.patch
@@ -0,0 +1,122 @@
+From 593ba012ac49065343f6bbf10adca5047414ce85 Mon Sep 17 00:00:00 2001
+From: michael-grunder <michael.grunder@gmail.com>
+Date: Sun, 4 May 2025 10:20:01 -0700
+Subject: [PATCH] Check for `dragonfly_version` in `HELLO` response
+
+DragonflyDB will report to be Redis but also include `dragonfly_version`
+in the hello response, which we can use to identify the fork.
+
+Also fix parsing of the `HELLO` response for `serverName()` and
+`serverVersion()`. Starting in Redis 8.0 there seem to always be modules
+running, which the previous function was not expecting or parsing.
+---
+ library.c | 39 ++++++++++++++++++++++++++-------------
+ redis.c | 2 +-
+ tests/RedisTest.php | 2 ++
+ 3 files changed, 29 insertions(+), 14 deletions(-)
+
+diff --git a/library.c b/library.c
+index a9fb523e48..ce3e2672d0 100644
+--- a/library.c
++++ b/library.c
+@@ -2018,26 +2018,31 @@ static int
+ redis_hello_response(INTERNAL_FUNCTION_PARAMETERS,
+ RedisSock *redis_sock, zval *z_tab, void *ctx)
+ {
+- int numElems;
+ zval z_ret, *zv;
++ int numElems;
+
+- if (read_mbulk_header(redis_sock, &numElems) < 0) {
+- if (IS_ATOMIC(redis_sock)) {
+- RETVAL_FALSE;
+- } else {
+- add_next_index_bool(z_tab, 0);
+- }
+- return FAILURE;
+- }
++ if (read_mbulk_header(redis_sock, &numElems) < 0)
++ goto fail;
+
+ array_init(&z_ret);
+- redis_mbulk_reply_zipped_raw_variant(redis_sock, &z_ret, numElems);
++
++ if (redis_read_multibulk_recursive(redis_sock, numElems, 0, &z_ret) != SUCCESS ||
++ array_zip_values_recursive(&z_ret) != SUCCESS)
++ {
++ zval_dtor(&z_ret);
++ goto fail;
++ }
+
+ if (redis_sock->hello.server) {
+ zend_string_release(redis_sock->hello.server);
+ }
+- zv = zend_hash_str_find(Z_ARRVAL(z_ret), ZEND_STRL("server"));
+- redis_sock->hello.server = zv ? zval_get_string(zv) : ZSTR_EMPTY_ALLOC();
++
++ if ((zv = zend_hash_str_find(Z_ARRVAL(z_ret), ZEND_STRL("dragonfly_version")))) {
++ redis_sock->hello.server = zend_string_init(ZEND_STRL("dragonfly"), 0);
++ } else {
++ zv = zend_hash_str_find(Z_ARRVAL(z_ret), ZEND_STRL("server"));
++ redis_sock->hello.server = zv ? zval_get_string(zv) : ZSTR_EMPTY_ALLOC();
++ }
+
+ if (redis_sock->hello.version) {
+ zend_string_release(redis_sock->hello.version);
+@@ -2063,6 +2068,14 @@ redis_hello_response(INTERNAL_FUNCTION_PARAMETERS,
+ }
+
+ return SUCCESS;
++
++fail:
++ if (IS_ATOMIC(redis_sock)) {
++ RETVAL_FALSE;
++ } else {
++ add_next_index_bool(z_tab, 0);
++ }
++ return FAILURE;
+ }
+
+
+@@ -4302,7 +4315,7 @@ redis_read_multibulk_recursive(RedisSock *redis_sock, long long elements, int st
+ elements--;
+ }
+
+- return 0;
++ return SUCCESS;
+ }
+
+ static int
+diff --git a/redis.c b/redis.c
+index 3f13a59888..629dd5c20b 100644
+--- a/redis.c
++++ b/redis.c
+@@ -2131,7 +2131,7 @@ redis_sock_read_multibulk_multi_reply_loop(INTERNAL_FUNCTION_PARAMETERS,
+
+ int num = atol(inbuf + 1);
+
+- if (num > 0 && redis_read_multibulk_recursive(redis_sock, num, 0, &z_ret) < 0) {
++ if (num > 0 && redis_read_multibulk_recursive(redis_sock, num, 0, &z_ret) != SUCCESS) {
+ return FAILURE;
+ }
+ }
+diff --git a/tests/RedisTest.php b/tests/RedisTest.php
+index e7854da442..1ebcc61e51 100644
+--- a/tests/RedisTest.php
++++ b/tests/RedisTest.php
+@@ -2476,6 +2476,7 @@ public function testServerInfo() {
+ $this->markTestSkipped();
+
+ $hello = $this->execHello();
++
+ if ( ! $this->assertArrayKey($hello, 'server') ||
+ ! $this->assertArrayKey($hello, 'version'))
+ {
+@@ -2486,6 +2487,7 @@ public function testServerInfo() {
+ $this->assertEquals($hello['version'], $this->redis->serverVersion());
+
+ $info = $this->redis->info();
++
+ $cmd1 = $info['total_commands_processed'];
+
+ /* Shouldn't hit the server */