Commit Graph

3371 Commits

Author SHA1 Message Date
michael-grunder b97951cddc Rework TLS context logic
Instead of currying around a `php_stream_context` object, just retain
the context array provided by the user itself like we do with other
connection information like host and port. This lets users reconnect in
a loop without leaking memory.

```php
$redis = new \Redis;
while (true) {
    // Previously each reconnect call would leak the
    // `php_stream_context` structure.
    $redis->connect('tls://127.0.0.1', 9999, 1, null, 0, 0, [
        'stream' => ['verify_peer' => false, 'verify_peer_name' => false],
    ]);

    $redis->ping();

    $redis->close();
}
```
2026-02-18 09:46:55 -08:00
Pavlo Yatsukhnenko 3568497c45 Merge pull request #2806 from phpredis/fix/stubs
Fix typo
2026-02-16 19:01:14 +02:00
Pavlo Yatsukhnenko 9f4302c0cc Fix typo 2026-02-16 10:46:25 +02:00
michael-grunder 93cb921158 Minor DELEX refactor
We had a `delExType` enum which was later made redundant by
`redisEqType` as they have the same semantics.

This commit just removes `delExType` and uses the new enum.
2026-02-02 00:17:43 -08:00
michael-grunder 6f42a3493d Add a regression test for numeric strinig fields and key names
See #2795, #2796
2026-01-13 17:46:31 -08:00
Pavlo Yatsukhnenko 7c1c125974 Fix issue with numeric strings as hash fields 2026-01-12 11:08:45 -08:00
michael-grunder cab0505155 Fix deserializing non-string keys
In `array_zip_values_and_scores` we were blindly calling `Z_STR_P` on
the `zval` assuming it must be a string.

This isn't the case however if the user did something like this:

```php
$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
$redis->zAdd('zs', 3.14, ['pi', 'is', 'cool']);

// segfault when we try to get `Z_STR_P` from `['pi', 'is', 'cool']`
$redis->zRange('zs', 0, -1, true);
```

Potential fix for #2791
2026-01-09 09:04:38 -08:00
Pavlo Yatsukhnenko 8f8272dbf1 Migrate to php/php-windows-builder for Windows builds 2026-01-09 08:35:44 -08:00
Emre Çalışkan a6313d1bda fixed "tee: /opt/homebrew/etc/php/8.5/conf.d/90-redis.ini: No such file or directory" 2025-12-01 09:01:00 -08:00
Emre Çalışkan ac54591d1e Added 8.5 to Mac and Windows CI 2025-12-01 09:01:00 -08:00
michael-grunder 0debad4c83 Relax the _digest() test for PHP < 8.1
Just make sure the method is sound. We don't really care about specific
exception messages.
2025-11-27 12:23:46 -08:00
michael-grunder d4600a2846 docs: Update rendered docs 2025-11-26 18:22:57 -08:00
michael-grunder 399346e51a docs: Add a few missinig examples 2025-11-26 18:22:57 -08:00
michael-grunder 4baad44bcf Handle false from $this->redis->info() in TestSuite::setUp()
Technically `INFO` can return false in the event of a protocol error or
similar. If that happens the tests are unlikely to be useful but we
should at least account for it to avoid an immediate fatal error when
calling helpers like `detectKeyDB` and `detectValkey`.

See #2783
2025-11-25 14:43:28 -08:00
michael-grunder f23da62a9b Add missing type results and remove ancient TODO line 2025-11-18 22:41:39 -08:00
michael-grunder a033e40b7b Fix MSETEX TTL assertions
We want to include the actual TTL itself in our range.
2025-11-18 11:19:52 -08:00
michael-grunder 6efd549a1a Clarify that Redis->connect() will throw on failure.
Fixes #2778
2025-11-18 10:56:26 -08:00
michael-grunder 23cc785989 Implement XACKDEL 2025-11-18 10:10:48 -08:00
michael-grunder b192b0e454 Try to fix an ifdef compilation issue
Fixes #2775
2025-11-16 14:18:35 -08:00
Niels Dossche 3401462e00 Replace lagcy WRONG_PARAM_COUNT macro with its definition
Depending on the version this can either throw or not, so we don't port
over the RETURN_THROWS() part of its definition.
2025-11-16 14:07:06 -08:00
Niels Dossche 7d4fa6137c Replace legacy ZEND_WRONG_PARAM_COUNT() alias with zend_wrong_param_count() 2025-11-16 14:07:06 -08:00
Niels Dossche d24528e190 Replace legacy zval_dtor() alias with zval_ptr_dtor_nogc() 2025-11-16 14:07:06 -08:00
Niels Dossche 8e1c2789a4 Replace legacy zval_is_true() alias with zend_is_true() 2025-11-16 14:07:06 -08:00
michael-grunder c17f475caa docs: Add missing docblocs + example highlighting 2025-11-13 17:36:55 -08:00
michael-grunder 0981c2b7d7 docs: Document failover strategies. 2025-11-12 10:23:35 -08:00
michael-grunder 8ef349a2d9 docs: Document final undocumented constants. 2025-11-12 10:23:35 -08:00
michael-grunder 26cf6d9494 docs: Fully document backof strategies. 2025-11-12 10:23:35 -08:00
michael-grunder 49919b0ec5 docs: Document class constants 2025-11-12 10:23:35 -08:00
michael-grunder 8b4cfb725f Add a test for XDELEX 2025-11-12 09:14:43 -08:00
michael-grunder 635d87d535 Implement XDELEX command 2025-11-12 09:14:43 -08:00
michael-grunder 41922b6740 Implement MSETEX for RedisCluster
We also need to revisit the multi key command logic (MSET, DEL, and
friends). We may want to create a "per slot" distribution mechanism.
2025-11-12 08:41:21 -08:00
michael-grunder bd4989e004 Add a test for MSETEX 2025-11-12 08:41:21 -08:00
michael-grunder 86eabb86eb Implement MSETEX and refactor SET.
* Implement the new `MSETEX` Redis command.
* Refactor parsing of extended `SET` arguments into unified helper
  functions, deduplicating logic.
* Add new `SET` arguments `IFNE`, `IFDEQ`, and `IFDNE`. We already
  support Valkey's existing `IFEQ` argument, which Redis has added.

Fixes #2742
2025-11-12 08:41:21 -08:00
michael-grunder 730dec06b6 Add a monotonically incrementing persistent id counter
When a persistent ID is not provided, we were generating a "unique" one
by constructing a string with the current seconds and microseconds.

If two connections are createed in rapid succession, they can both
generate the same `persistent_id` and therefore both use the same
underlying `php_stream`.

```php
$r1 = new Redis;
$r2 = new Redis;

// If the two of these execute on the same second and usec, they will both use
// the same persistent_id and therefore the same underlying socket.
$r1->pconnect('localhost', 6379);
$r2->pconnect('localhost', 6379);

// Close and free the first connection
$r1->close();

// Segfault. Closing an already closed stream
$r2->close();
```

This commit simply adds a function scoped static monotonically
incremented counter which is used to make the persistent id's truly unique.

Fixes #2762
2025-11-11 10:34:36 -08:00
michael-grunder 76286d88a9 docs: Add @see annotations to the Redis or Valkey command docs 2025-11-11 09:22:31 -08:00
michael-grunder a46700cfc8 docs: Fix @see \Redis annotations so they hyperlink correctly.
It turns out `doctum` will only hyperlink to the Redis methods when the
method casing is identical. For that reason, just match the casing in
`redis_cluster.stub.php` to how it's cased in `redis.stub.php`.

We aren't changing any of the non-commented stub text, just the casing of the
`@see` annotations.

WIP: More

.
2025-11-11 09:22:31 -08:00
Pavlo Yatsukhnenko e9e338b567 Fix parsing string values that looks like numbers in exponent form 2025-11-11 09:22:19 -08:00
michael-grunder d5b1576e27 docs: Syntax highlight parameter arg names 2025-11-10 21:17:57 -08:00
michael-grunder 5fe0862109 docs: Syntax highlight string literals in green 2025-11-09 18:17:42 -08:00
michael-grunder 38e56d5738 docs: Highlight the individual doctum params 2025-11-09 18:17:42 -08:00
michael-grunder 9edc242579 docs: Apply syntax highlighting to the index section. 2025-11-09 18:17:42 -08:00
michael-grunder d45c4d294c docs: We want our docs based on develop not main 2025-11-09 18:17:42 -08:00
Michael Grunder ae69e47a08 Additional doctum syntax highlighting. (#2763)
* docs: Syntax highlight ```php ... ``` code blocks

* docs: More syntax highlighting

* docs: Allow `highlight.js` to syntax highlight `Redis`.

* docs: Rebuild doctum static files
2025-11-09 16:24:16 -08:00
michael-grunder 9b17434e3d Update .gitignore 2025-11-08 21:26:37 -08:00
michael-grunder 4cf670fed3 docs: Add syntax highlighting to method signatures 2025-11-08 21:26:37 -08:00
michael-grunder e460a8595a docs: Add doctum theme and syntax highlighting 2025-11-08 21:26:37 -08:00
michael-grunder 1297c48c14 docs: Initial syntax highlighing integration 2025-11-08 21:26:37 -08:00
michael-grunder b30fe1d1c7 Add vendor to .gitignore 2025-11-08 14:31:14 -08:00
michael-grunder 9e9ccbd441 Update doctum docs 2025-11-08 14:13:56 -08:00
michael-grunder abce1655b9 Add examples to methods missing them. 2025-11-08 14:13:56 -08:00