-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
We recently noticed an issue on our servers caused by an upgrade from php-redis 4.3.0 to 5.0.2. Previously we were passing null
as the port number to connect()
which would result in the default Redis port being used, but since 5.0.2 we've noticed that this behaviour has changed unexpectedly.
This problem is briefly mentioned in #1602 : passing null
now appears to trigger the extension to try and connect to a socket, displaying the exception No such file or directory which seemed fairly nonsensical when it appeared to us that we were connecting to a network location.
Expected behaviour
Either
- Passing
null
as the second argument (port number) toconnect()
should automatically use the default port (6379), as it did in version <=4.3.0 - Exception message should be clarified (e.g. Failed to connect to socket: {socket path}: No such file or directory)
Actual behaviour
Pasing null
as the port number fails with the message No such file or directory.
I'm seeing this behaviour on
- OS:
- Linux 4.9.0-9-amd64 renameNx delivers false on success #1 SMP Debian 4.9.168-1+deb9u4 (2019-07-19)
- Linux 4.4.0-17134-Microsoft Avoiding conditional directives that split up statements. #706-Microsoft Mon Apr 01 18:13:00 PST 2019
- Redis: 3:3.2.6-3+deb9u3
- PHP:
- PHP 7.3.8-1+0~20190807.43+debian9~1.gbp7731bf (CLI and FPM)
- PHP 7.0.33-0+deb9u3 (CLI)
- phpredis:
- 5.0.0
- 5.0.1
- 5.0.2
Steps to reproduce, backtrace or example script
#!/usr/bin/php
<?php
try {
$redis = new Redis();
if($redis->connect("127.0.0.1", null)) {
print("null ok\n");
}
if($redis->connect("127.0.0.1")) {
print("omit ok\n");
}
} catch (Exception $e) {
print($e->getMessage() . "\n");
}
?>
Install 4.3.0 from pecl (pecl install redis-4.3.0
) and run the above script
Uninstall 4.3.0, then install any 5.0.x from pecl (pecl install redis-5.0.x
) and run the above script.
I've checked
- There is no similar issue from other users
- Issue isn't fixed in
develop
branch