212 Commits

Author SHA1 Message Date
michael-grunder e52f0afaed Update SCAN to handle very large cursor values.
Technically Redis may return any unsigned 64 bit integer as a scan
cursor.  This presents a problem for PHP in that PHP's integers are
signed.  Because of that if a scan cursor is > 2^63 it will overflow and
fail to work properly.

This commit updates our SCAN family of commands to deliver cursors in
their string form.

```php
public function scan(null|int|string $iterator, ...);
```

On initial entry into our SCAN family we convert either a NULL or empty
string cursor to zero, and send the initial scan command.

As Redis replies with cursors we either represent them as a long (if
they are <= ZEND_ULONG_MAX) and as a string if greater.  This should
mean the fix is minimally breaking as the following code will still
work:

```php
$it = NULL;
do {
    print_r($redis->scan($it));
} while ($it !== 0);
```

The `$it !== 0` still works because the zero cursor will be represented
as an integer.  Only absurdly large (> 2^63) values are represented as a
string.

Fixes #2454
2024-03-17 10:59:14 -07:00
Remi Collet 3675f442e4 mark auth param as sensitive for PHP 8.2
refactor MINIT (split in each class sources file)
use @generate-class-entries in stub files
add RedisException and RedisClusterException in stub files
2022-07-18 13:45:45 +02:00
Pavlo Yatsukhnenko 8689ab1c17 Issue #1393 2022-01-30 10:16:46 -08:00
Pavlo Yatsukhnenko 08a9d5db91 Issue #2055 2022-01-20 11:43:10 -08:00
Pavlo Yatsukhnenko 8751a92c03 Duplicate zval before add_next_index_zval 2021-12-28 16:40:58 +02:00
Pavlo Yatsukhnenko ebc33a35ee Fix RedisArray::__construct bug 2021-09-07 20:47:28 +03:00
Pavlo Yatsukhnenko c8ae539523 Use stub/arginfo for RedisArray 2021-08-26 09:53:51 +03:00
Remi Collet edac508ef5 use stub/arginfo for RedisSentinel 2021-08-26 09:52:40 +03:00
Remi Collet 21cce7844d cleanup unneeded cast 2021-03-25 09:16:27 +01:00
Remi Collet c93eba4a4f Fix #1956 bad type usage on 32-bit 2021-03-25 08:54:15 +01:00
Pavlo Yatsukhnenko ee82299666 Add accidentally removed header 2020-12-13 09:57:12 +02:00
Pavlo Yatsukhnenko 7d67749b81 Remove odd PHPREDIS_ZVAL_IS_STRICT_FALSE macro 2020-12-12 20:54:39 +02:00
Pavlo Yatsukhnenko de985150cf Remove aliases for all methods. 2020-12-08 11:59:11 +02:00
Pavlo Yatsukhnenko 43a39afb91 Duplicate zval before add_next_index_zval 2020-10-30 21:23:25 +02:00
Pavlo Yatsukhnenko d67e360e1b Refactor ra_generic_del 2020-10-30 18:26:56 +02:00
Pavlo Yatsukhnenko 6ca64a1c75 Refactor RedisArray 2020-10-30 18:09:32 +02:00
Pavlo Yatsukhnenko 2634350ea9 Use zend_string in ra_find_node_by_name 2020-10-30 15:52:34 +02:00
Michael Grunder a311cc4ec3 Support for Redis 6 ACLs (#1791)
Add support for Redis 6 ACLs in the `Redis`, `RedisCluster`, and `RedisArray` classes.

On a related note, it adds a mechanism for users to customize how we generate persistent connection IDs such that they can be grouped in different ways depending on the specific use case required (e.g. it would allow connections to be grouped by username, or by user-defined persistent_id, or both).
2020-06-24 17:00:01 -07:00
Remi Collet b9b383f499 fix [-Wformat=] warning on 32-bit (#1750)
Use the portable `ZEND_LONG_FORMAT` family instead of C format specifiers
2020-05-06 09:46:43 -07:00
Pavlo Yatsukhnenko 35372a1f64 Authenticate in redis_sock_server_open 2020-03-30 22:34:12 +03:00
Pavlo Yatsukhnenko d5dadaf635 Add PHPREDIS_GET_OBJECT and PHPREDIS_ZVAL_GET_OBJECT macros 2020-03-09 13:36:27 +02:00
Tyson Andre 0ef488fca7 Remove "PHP Version 5" section
package.xml has a minimum version of 7.0
PHP 8.0 will probably be out in around a year.
2020-01-13 18:41:03 -05:00
Pavlo Yatsukhnenko c0db75b5ac Fix coverity scan warnings 2019-10-05 20:23:16 +03:00
Pavlo Yatsukhnenko fbe0f804bc Issue #1618
This commit fixes regression added in 112c77e3
2019-08-09 15:10:05 +03:00
Remi Collet d6fc5c7348 use uint32_t for call_user_function 2019-07-18 10:41:41 +02:00
Remi Collet b4eb158a00 ulong => zend_ulong for 7.4 2019-07-18 10:37:02 +02:00
Remi Collet 943802272a cleanup TSRMLS_* usage 2019-07-09 15:26:44 +02:00
Michael Grunder 60d8b679b3 Handle references in MGET (#1535)
Fixes #1534
2019-03-28 22:02:27 -07:00
michael-grunder 2761c607e2 Merge remote-tracking branch 'cthulhu/issue.1448-require_php7' into issue.1448-require_php7 2019-03-19 11:30:14 -07:00
Pavlo Yatsukhnenko 112c77e3a1 Issue #1508
Wrap all calls of `call_user_function` into `ra_call_user_function`
where AUTH command sended before function call.
2019-03-19 11:28:00 -07:00
Pavlo Yatsukhnenko 5053a9e7e4 RedisArray auth.
Issue #1508
2019-03-19 11:10:08 -07:00
Pavlo Yatsukhnenko 0d2dd169fa Use zend_string for storing key hashing algorithm 2019-03-19 11:09:26 -07:00
michael-grunder fa130a4bd4 PHP 7 exception and compiler warning fixes
PHP 7 removed TSRMLS_CC from zend_throw_exception* routines.
Additionally this commit creates two simple wrapper macros for throwing
Redis or RedisCluster exceptions so we don't duplicate as much code.

Additionally there were a couple of minor compiler warnings printf type
correctness fixed in this commit.
2019-02-08 21:31:47 -08:00
michael-grunder f9928642b5 PHP 5 is dead, long live PHP 7
This commit removes support for PHP 5 by getting rid of all of our Zend
compatibility layer methods, as well as any call checking against
PHP_MAJOR_VERSION or ZEND_MODULE_API_NO.

Unit tests are all passing for Redis, RedisCluster, and RedisArray but
this should still be considered a work in progress until more testing
can be done.

Addresses issue #1448
2019-01-26 20:57:16 -08:00
Pavlo Yatsukhnenko 850027ffd3 Different key hashing algorithms from hash extension. 2019-01-03 16:17:20 +02:00
Pavlo Yatsukhnenko 71922bf1dd Add RedisArray::_continuum method 2018-12-22 15:31:51 +02:00
Pavlo Yatsukhnenko bb32e6f3a0 Implement consistent hashing algorithm for RedisArray 2018-12-22 15:31:51 +02:00
Pavlo Yatsukhnenko 602740d35a Use zend_string for storing RedisArray hosts 2018-12-19 10:16:54 +02:00
Michael Grunder 2c9e057236 Streams (#1413)
Streams API
2018-09-29 11:59:01 -07:00
Pavlo Yatsukhnenko 742cdd0594 Issue #1302
Handle async parameter for RedisCluster::flushDb and RedisCluster::flushAll
2018-04-22 22:26:13 +03:00
Pavlo Yatsukhnenko acd10409bc Issue #1302
Handle async parameter for RedisArray::flushDb and RedisArray::flushAll
TODO: implementation for RedisCluster and unit-tests
2018-04-22 22:26:13 +03:00
Pavlo Yatsukhnenko 1689318021 Refactor RedisArray
Add `multihost_distribute_call` function for iterating over RA hosts
and store results of functions into `return_value` array.
2018-04-11 00:03:34 +03:00
michael-grunder a4afe91909 Some style normalization 2018-02-17 09:47:28 -08:00
Pavlo Yatsukhnenko 9cd059117a Refactor RedisArray
Change type of returning value from `char *` to `zend_string *` for
`ra_extract_key` and `ra_call_extractor` functions.
Store keys as `zend_string *` in RedisArray::mset.
2018-01-29 22:37:36 +02:00
michael-grunder 04f62acbc8 Syntax fixes and prototype consolidation
Fix PHP_METHOD syntax fail for unlink
Move redis_unlink_cmd by redis_del_cmd as they're the same
2018-01-17 10:34:08 -08:00
michael-grunder 9e65c42931 Implement UNLINK command
This commit implements UNLINK for Redis, RedisCluster, and RedisArray.
To a client library UNLINK behaves identically to DEL so we can use the
same handlers for both.
2018-01-17 09:36:38 -08:00
Pavlo Yatsukhnenko 9d15f07adb Issue #1224 2017-10-20 16:46:05 +03:00
Pavlo Yatsukhnenko 0115666e59 Add PHPREDIS_GET_OBJECT macros 2017-10-05 15:27:18 +03:00
michael-grunder 345fc7fc9f Destroy all tabs :-) 2017-09-28 15:44:18 -07:00
Pavlo Yatsukhnenko 6a53cb99ba Revert "Fix RA memory leak"
This reverts commit 5241bcb883.
2017-09-28 22:33:31 +03:00