151 Commits

Author SHA1 Message Date
Anton Smirnov
8dada174c4 Add an INI setting returning 5.x legacy behavior -- readonly session on lock failure 2025-07-09 20:07:57 -07:00
peter15914
43e6cab879 Fix potential NULL dereference
The return value of INI_STR() is always checked for NULL.
2025-01-02 11:34:52 -08:00
michael-grunder
085d61ecfb Create a strncmp wrapper
On some glibc implementations strncmp is a macro. This commit simply creates a
`redis_strncmp` static inline wrapper function so we can `ZEND_STRL` instead of
manually counting the length or using `sizeof(s)-1` each time.

Fixes #2565
2024-10-15 10:40:15 -07:00
Remi Collet
37cebdd70b cleanup code for unsupported versions 2024-08-05 08:58:58 -07:00
michael-grunder
3d7be35816 Consolidate failure path 2024-04-09 12:58:45 -07:00
michael-grunder
0e92616591 Fix memory leak if we fail in ps_open_redis. 2024-04-09 12:58:45 -07:00
michael-grunder
2b555c89ef Minor session compression cleanup.
* We can compress without the need for sepearate buffers.
* Allow both "" and "none" to mean "none" in terms of
  redis.session.compression.
2024-04-08 15:11:52 -07:00
bitactive
da4ab0a72c Add compression support for PHP Sessions (#2473)
* Add compression support for PHP Sessions

Previously, compression was available for standard data but not for
session handling. This update enables the compression of PHP sessions,
allowing for more efficient Redis memory usage.

* Move session compress/uncompress logic to helper functions

* Change session_compress_data to always set the out arguments and adjust PS_READ_FUNC
2024-04-08 14:40:15 -07:00
Bitactive
b698901818 Support for early_refresh in Redis sessions to match cluster behavior
Previously, the redis.session.early_refresh feature was implemented for
Redis Cluster, utilizing GETEX for the initial session read to minimize
the number of commands sent to the Redis server. However, this enhancement
was not applied to non-cluster sessions. This update addresses this
discrepancy, ensuring consistent behavior between Redis and Redis Cluster.
2024-03-28 13:19:47 -07:00
Viktor Szépe
37c5f8d451 Fix typos 2024-02-21 13:16:12 -08:00
thomaston
a3327d9d2b Fix bug: the pipeline mode socket return an unexpected result after reconnecting (#2358)
* fix bug: the pipeline mode socket return an unexpected result after reconnecting

* fix typos: pipeline is right

---------

Co-authored-by: marcofu <marcofu@tencent.com>
2023-07-20 11:48:53 -07:00
Pavlo Yatsukhnenko
6930a81cb4 Auto-select db in redis_sock_server_open 2023-04-02 14:24:41 +03:00
zorro-fr24
b6cf6361dd Add cluster support for strict sessions and lazy write
* Add ini setting redis.session.early_refresh to allow for session TTL updates on session start ( requires redis server version 6.2 or greater )
 * Enable cluster session support for strict mode sessions ( via PS_VALIDATE_SID_FUNC )
 * Cluster sessions used to write on every session, now we only write if the session has been modified.
 * Send EXPIRE instead of SETEX if sessioh has not been changed
 * If early refresh is enabled use GETEX for initial session read
 * When strict sessions are enabled, check whether the session exists first, validate sid and regenerate if necessary
2022-12-06 10:45:52 -08:00
Michael Grunder
b3ce048669 Fix non standards conforming prototypes. (#2150)
These now generate warnings with GCC 13
2022-09-14 22:54:22 -07:00
Pavlo Yatsukhnenko
a471c87a3b Issue #2141
Fix segfault with session+tls
2022-08-21 14:59:39 +03:00
patricio.dorantes
2ff11df528 redis_session clean up ssl context. 2022-08-03 10:57:01 -05:00
patricio.dorantes
d1bc672752 fix use after free, initialize on NULL 2022-08-02 17:36:54 -05:00
patricio.dorantes
ed10f365e7 fix redis session standalone stream ssl context 2022-08-01 11:16:24 -05:00
michael-grunder
306fa25c19 Smaller default retry count
See #1908
2021-03-09 11:25:29 -08:00
Mike Griego
687a0b4050 Fail if session lock can't be acquired, more sane lock wait defaults, and add more logging. 2021-03-09 11:09:06 -08:00
Pavlo Yatsukhnenko
a8daaff87a Issue #1782
Allow to specify stream context for rediscluster session handler.
2020-09-08 17:58:08 +03:00
Pavlo Yatsukhnenko
b2cffffc10 Fix memory leak in rediscluster session handler 2020-08-14 16:56:32 +03:00
michael-grunder
066cff6ade Proper cleanup and conditional address deallocation.
See: #1807
2020-07-07 09:41:39 -07:00
michael-grunder
7fed60f248 We don't want to efree a zend_string 2020-07-06 13:16:30 -07:00
Michael Grunder
ff2e160f40 Don't attempt to take ZSTR_VAL(NULL) (#1804)
Fixes #1798
2020-07-02 09:56:54 -07: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
Michael Grunder
5ca4141c72 Issue.1765 (#1774)
Various improvements and fixes to cluster slot caching.

* Improves slot caching so any unique set of seeds all hash to the same key

* Fix a couple of memory leaks.

* Fixes a segfault when executing a multiple key command such as `MGET` or `MSET` while the cluster is resharding.
2020-06-07 13:50:22 -07:00
Pavlo Yatsukhnenko
58dab5649f Store auth information in cluster->flags->auth 2020-06-05 10:27:48 +03:00
Pavlo Yatsukhnenko
35372a1f64 Authenticate in redis_sock_server_open 2020-03-30 22:34:12 +03: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
michael-grunder
7a79ad9c27 Also protect against session.gc_maxlifetime <= 0
Addresses #1694
2020-01-10 09:47:58 -08:00
michael-grunder
3c48a332d2 Protect session.gc_maxlifetime from integer overflow 2020-01-10 09:47:58 -08:00
Tyson Andre
f52bd8a853 Fix typos detected by codespell 2020-01-06 09:08:36 -05:00
Michael Booth
23b1a9d84c Enable slot caching for session cluster 2019-12-02 09:00:12 +00:00
Pavlo Yatsukhnenko
53a8bcc7a9 Issue #1657
Allow to specify schema for session handler.
2019-10-26 17:54:27 +03:00
Pavlo Yatsukhnenko
2bb086802e Issue #1631 2019-10-07 15:00:36 +03:00
Pavlo Yatsukhnenko
91a8e73441 Refactor redis_session
Use strpprintf instead of zend_string_alloc + memcpy.
2019-07-27 21:03:23 +03:00
Pavlo Yatsukhnenko
7d4470a735 Refactor redis_session
Remove `refresh_lock_status` helper function
2019-07-24 22:00:45 +03:00
Pavlo Yatsukhnenko
978c307456 Refactor redis_session
Use `redis_sock` to store `auth` and `prefix` for session.
Use `redis_sock_auth` insted of `redis_pool_member_auth`.
2019-07-23 22:16:56 +03:00
Remi Collet
943802272a cleanup TSRMLS_* usage 2019-07-09 15:26:44 +02:00
Pavlo Yatsukhnenko
5ab0e71c76 Don't check lock status in PS_UPDATE_TIMESTAMP_FUNC 2019-02-11 19:58:28 -08:00
Pavlo Yatsukhnenko
50881ddd69 Don't check the number affected keys in PS_UPDATE_TIMESTAMP_FUNC 2019-02-11 19:54:58 -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
3aad9e653b Merge pull request #1494 from phpredis/cluster-auth2
RedisCluster auth
2019-01-21 11:57:35 +02:00
Pavlo Yatsukhnenko
35a2213d30 Merge pull request #1485 from phpredis/consistent-hashing
Implement consistent hashing algorithm for RedisArray
2019-01-21 10:57:40 +02:00
Pavlo Yatsukhnenko
c5994f2a42 RedisCluster auth 2019-01-17 23:05:52 +02:00
Marius Meissner
61889cd7ba PHPREDIS-1412: Breaking the lock acquire loop in case of network problems 2018-12-27 10:30:39 +01:00
Pavlo Yatsukhnenko
bb32e6f3a0 Implement consistent hashing algorithm for RedisArray 2018-12-22 15:31:51 +02:00
Pavlo Yatsukhnenko
c0793e8be4 Remove unused parameter lazy_connect from redis_sock_create 2018-11-21 13:39:50 +02:00
Pavlo Yatsukhnenko
4e2de1581f Fix redis_session
Prevent infinite loop when redis_sock_server_open failed.
Check pool->lock_status.session_key is not NULL in PS_CLOSE_FUNC.
2018-11-07 17:48:58 +02:00