summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--0b97ec3739d99f0778ff827cb58c011b92d27a74.patch122
-rw-r--r--2e412373c47a574a1215756e79e6512a46e30cdc.patch61
-rw-r--r--php-pecl-redis4.spec10
3 files changed, 192 insertions, 1 deletions
diff --git a/0b97ec3739d99f0778ff827cb58c011b92d27a74.patch b/0b97ec3739d99f0778ff827cb58c011b92d27a74.patch
new file mode 100644
index 0000000..14d8d8b
--- /dev/null
+++ b/0b97ec3739d99f0778ff827cb58c011b92d27a74.patch
@@ -0,0 +1,122 @@
+From 0b97ec3739d99f0778ff827cb58c011b92d27a74 Mon Sep 17 00:00:00 2001
+From: michael-grunder <michael.grunder@gmail.com>
+Date: Thu, 18 Oct 2018 09:47:10 -0700
+Subject: [PATCH] Update STREAM API to handle STATUS -> BULK reply change
+
+Right before Redis 5.0 was released, the api was changed to send
+message ids as BULK instead of STATUS replies.
+---
+ library.c | 35 ++++++++++++++++++++++-------------
+ redis.c | 2 +-
+ redis_cluster.c | 2 +-
+ 3 files changed, 24 insertions(+), 15 deletions(-)
+
+diff --git a/library.c b/library.c
+index 8fecaef1..d5752f0d 100644
+--- a/library.c
++++ b/library.c
+@@ -1269,17 +1269,18 @@ redis_read_stream_messages(RedisSock *redis_sock, int count, zval *z_ret
+ {
+ zval zv, *z_message = &zv;
+ int i, mhdr, fields;
+- char id[1024];
+- size_t idlen;
++ char *id = NULL;
++ int idlen;
+
+ /* Iterate over each message */
+ for (i = 0; i < count; i++) {
+ /* Consume inner multi-bulk header, message ID itself and finaly
+ * the multi-bulk header for field and values */
+ if ((read_mbulk_header(redis_sock, &mhdr TSRMLS_CC) < 0 || mhdr != 2) ||
+- redis_sock_read_single_line(redis_sock, id, sizeof(id), &idlen, 0 TSRMLS_CC) < 0 ||
++ ((id = redis_sock_read(redis_sock, &idlen TSRMLS_CC)) == NULL) ||
+ (read_mbulk_header(redis_sock, &fields TSRMLS_CC) < 0 || fields % 2 != 0))
+ {
++ if (id) efree(id);
+ return -1;
+ }
+
+@@ -1289,6 +1290,7 @@ redis_read_stream_messages(RedisSock *redis_sock, int count, zval *z_ret
+ redis_mbulk_reply_loop(redis_sock, z_message, fields, UNSERIALIZE_VALS TSRMLS_CC);
+ array_zip_values_and_scores(redis_sock, z_message, SCORE_DECODE_NONE TSRMLS_CC);
+ add_assoc_zval_ex(z_ret, id, idlen, z_message);
++ efree(id);
+ }
+
+ return 0;
+@@ -1404,24 +1406,30 @@ PHP_REDIS_API int
+ redis_read_xclaim_response(RedisSock *redis_sock, int count, zval *rv TSRMLS_DC) {
+ zval zv, *z_msg = &zv;
+ REDIS_REPLY_TYPE type;
+- char id[1024];
+- int i, fields;
++ char *id;
++ int i, fields, idlen;
+ long li;
+- size_t idlen;
+
+ for (i = 0; i < count; i++) {
+ /* Consume inner reply type */
+ if (redis_read_reply_type(redis_sock, &type, &li TSRMLS_CC) < 0 ||
+- (type != TYPE_LINE && type != TYPE_MULTIBULK)) return -1;
++ (type != TYPE_BULK && type != TYPE_MULTIBULK) ||
++ (type == TYPE_BULK && li <= 0)) return -1;
+
+- if (type == TYPE_LINE) {
+- /* JUSTID variant */
+- if (redis_sock_gets(redis_sock, id, sizeof(id), &idlen TSRMLS_CC) < 0)
++ /* TYPE_BULK is the JUSTID variant, otherwise it's standard xclaim response */
++ if (type == TYPE_BULK) {
++ if ((id = redis_sock_read_bulk_reply(redis_sock, (size_t)li TSRMLS_CC)) == NULL)
+ return -1;
+- add_next_index_stringl(rv, id, idlen);
++
++ add_next_index_stringl(rv, id, li);
++ efree(id);
+ } else {
+- if (li != 2 || redis_sock_read_single_line(redis_sock, id, sizeof(id), &idlen, 0 TSRMLS_CC) < 0 ||
+- (read_mbulk_header(redis_sock, &fields TSRMLS_CC) < 0 || fields % 2 != 0)) return -1;
++ if ((li != 2 || (id = redis_sock_read(redis_sock, &idlen TSRMLS_CC)) == NULL) ||
++ (read_mbulk_header(redis_sock, &fields TSRMLS_CC) < 0 || fields % 2 != 0))
++ {
++ if (id) efree(id);
++ return -1;
++ }
+
+ REDIS_MAKE_STD_ZVAL(z_msg);
+ array_init(z_msg);
+@@ -1429,6 +1437,7 @@ redis_read_xclaim_response(RedisSock *redis_sock, int count, zval *rv TSRMLS_DC)
+ redis_mbulk_reply_loop(redis_sock, z_msg, fields, UNSERIALIZE_VALS TSRMLS_CC);
+ array_zip_values_and_scores(redis_sock, z_msg, SCORE_DECODE_NONE TSRMLS_CC);
+ add_assoc_zval_ex(rv, id, idlen, z_msg);
++ efree(id);
+ }
+ }
+
+diff --git a/redis.c b/redis.c
+index b8244718..2718997c 100644
+--- a/redis.c
++++ b/redis.c
+@@ -3592,7 +3592,7 @@ PHP_METHOD(Redis, xack) {
+ }
+
+ PHP_METHOD(Redis, xadd) {
+- REDIS_PROCESS_CMD(xadd, redis_single_line_reply);
++ REDIS_PROCESS_CMD(xadd, redis_read_variant_reply);
+ }
+
+ PHP_METHOD(Redis, xclaim) {
+diff --git a/redis_cluster.c b/redis_cluster.c
+index 130b961a..8f10bcb0 100644
+--- a/redis_cluster.c
++++ b/redis_cluster.c
+@@ -2983,7 +2983,7 @@ PHP_METHOD(RedisCluster, xack) {
+
+ /* {{{ proto string RedisCluster::xadd(string key, string id, array field_values) }}} */
+ PHP_METHOD(RedisCluster, xadd) {
+- CLUSTER_PROCESS_CMD(xadd, cluster_single_line_resp, 0);
++ CLUSTER_PROCESS_CMD(xadd, cluster_bulk_raw_resp, 0);
+ }
+
+ /* {{{ proto array RedisCluster::xclaim(string key, string group, string consumer,
diff --git a/2e412373c47a574a1215756e79e6512a46e30cdc.patch b/2e412373c47a574a1215756e79e6512a46e30cdc.patch
new file mode 100644
index 0000000..9140561
--- /dev/null
+++ b/2e412373c47a574a1215756e79e6512a46e30cdc.patch
@@ -0,0 +1,61 @@
+From 2e412373c47a574a1215756e79e6512a46e30cdc Mon Sep 17 00:00:00 2001
+From: michael-grunder <michael.grunder@gmail.com>
+Date: Fri, 12 Oct 2018 08:36:48 -0700
+Subject: [PATCH] Use a ZSET insted of SET for EVAL tests
+
+Redis SET type is unordered which could break our eval tests
+so use a ZSET instead where the order is deterministic.
+---
+ tests/RedisTest.php | 18 +++++++++---------
+ 1 file changed, 9 insertions(+), 9 deletions(-)
+
+diff --git a/tests/RedisTest.php b/tests/RedisTest.php
+index 28faafa8..e353829d 100644
+--- a/tests/RedisTest.php
++++ b/tests/RedisTest.php
+@@ -4508,10 +4508,10 @@ public function testEval() {
+ $this->redis->rpush('{eval-key}-list', 'c');
+
+ // Make a set
+- $this->redis->del('{eval-key}-set');
+- $this->redis->sadd('{eval-key}-set', 'd');
+- $this->redis->sadd('{eval-key}-set', 'e');
+- $this->redis->sadd('{eval-key}-set', 'f');
++ $this->redis->del('{eval-key}-zset');
++ $this->redis->zadd('{eval-key}-zset', 0, 'd');
++ $this->redis->zadd('{eval-key}-zset', 1, 'e');
++ $this->redis->zadd('{eval-key}-zset', 2, 'f');
+
+ // Basic keys
+ $this->redis->set('{eval-key}-str1', 'hello, world');
+@@ -4521,9 +4521,9 @@ public function testEval() {
+ $list = $this->redis->eval("return redis.call('lrange', KEYS[1], 0, -1)", Array('{eval-key}-list'), 1);
+ $this->assertTrue($list === Array('a','b','c'));
+
+- // Use a script to return our set
+- $set = $this->redis->eval("return redis.call('smembers', KEYS[1])", Array('{eval-key}-set'), 1);
+- $this->assertTrue($set == Array('d','e','f'));
++ // Use a script to return our zset
++ $zset = $this->redis->eval("return redis.call('zrange', KEYS[1], 0, -1)", Array('{eval-key}-zset'), 1);
++ $this->assertTrue($zset == Array('d','e','f'));
+
+ // Test an empty MULTI BULK response
+ $this->redis->del('{eval-key}-nolist');
+@@ -4539,7 +4539,7 @@ public function testEval() {
+ redis.call('get', '{eval-key}-str2'),
+ redis.call('lrange', 'not-any-kind-of-list', 0, -1),
+ {
+- redis.call('smembers','{eval-key}-set'),
++ redis.call('zrange','{eval-key}-zset', 0, -1),
+ redis.call('lrange', '{eval-key}-list', 0, -1)
+ }
+ }
+@@ -4559,7 +4559,7 @@ public function testEval() {
+ );
+
+ // Now run our script, and check our values against each other
+- $eval_result = $this->redis->eval($nested_script, Array('{eval-key}-str1', '{eval-key}-str2', '{eval-key}-set', '{eval-key}-list'), 4);
++ $eval_result = $this->redis->eval($nested_script, Array('{eval-key}-str1', '{eval-key}-str2', '{eval-key}-zset', '{eval-key}-list'), 4);
+ $this->assertTrue(is_array($eval_result) && count($this->array_diff_recursive($eval_result, $expected)) == 0);
+
+ /*
diff --git a/php-pecl-redis4.spec b/php-pecl-redis4.spec
index ff1763e..de69dde 100644
--- a/php-pecl-redis4.spec
+++ b/php-pecl-redis4.spec
@@ -34,11 +34,14 @@
Summary: Extension for communicating with the Redis key-value store
Name: %{?sub_prefix}php-pecl-redis4
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;')}}
Source0: http://pecl.php.net/get/%{pecl_name}-%{upstream_version}%{?upstream_prever}.tgz
License: PHP
URL: http://pecl.php.net/package/redis
+Patch0: https://github.com/phpredis/phpredis/commit/2e412373c47a574a1215756e79e6512a46e30cdc.patch
+Patch1: https://github.com/phpredis/phpredis/commit/0b97ec3739d99f0778ff827cb58c011b92d27a74.patch
+
BuildRequires: %{?dtsprefix}gcc
BuildRequires: %{?scl_prefix}php-devel
BuildRequires: %{?scl_prefix}php-pear
@@ -127,6 +130,8 @@ sed -e 's/role="test"/role="src"/' \
-i package.xml
cd NTS
+%patch0 -p1
+%patch1 -p1
# Use system library
rm -r liblzf
@@ -333,6 +338,9 @@ fi
%changelog
+* Sun Oct 21 2018 Remi Collet <remi@remirepo.net> - 4.2.0~RC1-2
+- test build with upstream patches
+
* Fri Oct 12 2018 Remi Collet <remi@remirepo.net> - 4.2.0~RC1-1
- update to 4.2.0RC1 (alpha)