Skip to content

[pull] develop from phpredis:develop #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 158 commits into
base: develop
Choose a base branch
from
Open

Conversation

pull[bot]
Copy link

@pull pull bot commented Jan 10, 2024

See Commits and Changes for more details.


Created by pull[bot]

Can you help keep this open source service alive? 💖 Please sponsor : )

@pull pull bot added the ⤵️ pull label Jan 10, 2024
woodongwong and others added 28 commits January 16, 2024 11:23
* Update zCount argument type in redis.stub.php

zCount's min/max can also be an integer.

* fix arginfo
* Add what value failed to pass our callback assertion so we can see
  what we actually got from the server.

* WAITAOF requires Redis >= 7.2.0 so don't run it if the server is older
  than that.
We actually had two different bits of logic to handle EXPIRY values in
the `SET` command.  One for the legacy `SET` -> `SETEX` mapping and
another for the newer `SET foo bar EX <expiry>`.

Additionally the error message could be confusing.  Passing 3.1415 for
an `EX` expiry would fail as we didn't allow floats.

This commit consolidates expiry parsing to our existing helper function
as well as improves the `php_error_docref` warning in the event that the
user passes invalid data.  The warning will now tell the user the type
they tried to pass as an EXPIRY to make it easier to track down what's
going wrong.

Fixes #2448
* We need both PHP_ADD_LIBRARY_WITH_PATH and PHP_ADD_INCLUDE

Fixes #2452

* Add an initial test block for ./configure correctness.
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
We also need to update the `RedisCluster` logic to handle very large
curosr values, in addition to handling them for the `Redis` and
`RedisArray` classes.

See #2454, #2458
PHP 8.4 has some breaking changes with respect to where PHP's random methods and
helpers are.  This commit fixes those issues while staying backward compatible.

Fixes #2463
Replace `SOCKET_WRITE_COMMAND` with `redis_sock_write` because it can't be used
with pre-defined commands (it frees memory in case of failed writing operation).
After replacement `SOCKET_WRITE_COMMAND` becomes redundant so remove it.
Fix segfault and remove redundant macros
This commit fixes our unit tests so they also pass against the KeyDB
server.  We didn't ned to change all that much.  Most of it was just
adding a version/keydb check.

The only change to PhpRedis itself was to relax the reply requirements
for XAUTOCLAIM.  Redis 7.0.0 added a third "these elements were recently
removed" reply which KeyDB does not have.

Fixes #2466
Mention support for KeyDB in README.md.

Remove credit for Owlient from the first paragraph. Owlient was acquired by Ubisoft in 2011, so presumably no longer benefit from such prominent credit.
Fix Arginfo / zpp mismatch for DUMP command
When a node timeout occurs, then phpredis will try to connect to another
node, whose answer probably will be MOVED redirect. After this we need
more time to accomplish the redirection, otherwise we get "Timed out
attempting to find data in the correct node" error message.

Fixes #795 #888 #1142 #1385 #1633 #1707 #1811 #2407
michael-grunder and others added 30 commits February 5, 2025 14:12
Adds an option that instructs PhpRedis to not serialize or compress
numeric values. Specifically where `Z_TYPE_P(z) == IS_LONG` or
`Z_TYPE_P(z) == IS_DOUBLE`.

This flag lets the user enable serialization and/or compression while
still using the various increment/decrement command (`INCR`, `INCRBY`,
`DECR`, `DECRBY`, `INCRBYFLOAT`, `HINCRBY`, and `HINCRBYFLOAT`).

Because PhpRedis can't be certain that this option was enabled when
writing keys, there is a small runtime cost on the read-side that tests
whether or not the value its reading is a pure integer or floating point
value.

See #23
* We want to run the logic if either a serializer OR a compression
  option is set.
* IEE754 doubles can theoretically have a huge number of characters.
For an error reply we're starting at `buf + 1` so we want `len - 1`. As
a sanity check we now return early if `len < 1`.

Also, make certain that len > 2 for our special detection of `*-1` since
we're doing `memcmp(buf + 1, "-1", 2);`
Redis and Valkey doesn't consider command as invalid if order of arguments
is changed but other servers like DragonflyDB does.
In this commit `SET` command is fixed to more strictly follow the specs.
Also fixed usage of `zend_tmp_string` for `ifeq` argument.
Right now we can't implement `HELLO` command to switch protocol
because we don't support new reply types that come with RESP3.
But we can use `HELLO` reply to expose some server information.
This lets a subclass override it
* cleanup session temp file

* Fix Deprecated: Automatic conversion of false to array
* New option 'database' for Redis class constructor

Selecting database is very common action after connecting to Redis. This simplifies lazy connecting to Redis, when requested database will be selected after first command.

* More specific exception message when invalid auth or database number is provided

Before it was just 'Redis server went away'

* Rename reselect_db method to redis_select_db and slightly optimise it
* Refactor `getWithMeta`

* Consolidate `getWithMeta()` test.

* Review comments
This method always unpack given string to zval, so it is not necessary to check output value
Deduplicate code that is used in many methods. Also optimise adding new element to array in pipeline mode and returning zval in atomic mode
Same fix as 6e5360d, with PHP switching from `ZEND_ASSUME` to `ZEND_ASSERT` in zend_hash_str_update_ptr.

Fixes #2648
`Redis::hGetAll()` returns an array indexed by `string`s and/or `int`s depending on the values in the hash set.

The function in the PHP stub was annotated as though the array were keyed only by strings, which is tighter than reality.
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.
Commands implemented:

`H[P]EXPIRE`
`H[P]TTL`
`H[P]EXPIREAT`
`H[P]EXPIRETIME`
`HPERSIST`
We often have to rerun the test suite on GitHub actions because of a
hard to reproduce "Read error on connection" exception when getting a
new `RedisCluster` instance.

No one has ever reported this failure outside of GitHub CI and it's not
clear exactly what might be going on.

This commit does two main things:

1. Allows for one failure to construct a new `RedisCluster` instance but
   only if we detect we're running in GitHub CI.

2. Adds much more diagnostic information if we still have a fatal error
   (e.g. we can't connect in two tries, or some other fatal error
   happens). The new info includes the whole callstack before aborting
   as well as an attempt to manually ping the seeds with `redis-cli`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.