Error trying to use redis with unix socket

My hosting provides redis connection with a unix socket. When I set:
$config[‘session_redis_server’] = ‘/home/user/ea-podman.d/ea-redis62.user.01/redis.sock’;
I get the error:
Redis::connect(): Passing null to parameter #2 ($port) of type int is deprecated
app/Tygh/Backend/Session/Redis.php, line: 183

Does the redis implementation not support sockets or am I missing something?

MV 4.18.3
PHP 8.1

1 Like

Thanks for the report!

Looking from the documentation to the Redis PHP Pear package:

In case of using unix socket, -1 should be passed as the port.

Please try applying these changes to your installation:

Index: app/Tygh/Backend/Cache/Redis.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/app/Tygh/Backend/Cache/Redis.php b/app/Tygh/Backend/Cache/Redis.php
--- a/app/Tygh/Backend/Cache/Redis.php	(revision 2a758beee183cecef86cf411b58409e800c5427c)
+++ b/app/Tygh/Backend/Cache/Redis.php	(date 1732091745418)
@@ -65,7 +65,7 @@
         $this->host = $config['cache_redis_server'];
 
         if (strncmp($this->host, '/', 1) === 0) {
-            $this->port = null;
+            $this->port = -1;
         } else {
             $parsed = parse_url($this->host);
 
Index: app/Tygh/Backend/Session/Redis.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/app/Tygh/Backend/Session/Redis.php b/app/Tygh/Backend/Session/Redis.php
--- a/app/Tygh/Backend/Session/Redis.php	(revision 2a758beee183cecef86cf411b58409e800c5427c)
+++ b/app/Tygh/Backend/Session/Redis.php	(date 1732091745411)
@@ -70,7 +70,7 @@
         $this->host = $config['session_redis_server'];
 
         if (strncmp($this->host, '/', 1) === 0) {
-            $this->port = null;
+            $this->port = -1;
         } else {
             $parsed = parse_url($this->host);
 

I have forwarded this issue to the developers.

The session cache is working with that, but cache_backend is throwing an error:
PHP Deprecated
Message
unserialize(): Passing null to parameter #1 ($data) of type string is deprecated
Error at
app/addons/hybrid_auth/func.php, line: 200

I used the diff like this:
patch -p1 < redis_socket_fix.diff
patching file app/Tygh/Backend/Cache/Redis.php
patching file app/Tygh/Backend/Session/Redis.php
patch unexpectedly ends in middle of line
Hunk #1 succeeded at 70 with fuzz 2.

The patch error might just be lack of CRLF at the end, I copied direct from your post. The redis.php files are showing the modification.

This is something unrelated. Could you please give me more details on how to reproduce this error?

Seems like the app/Tygh/Backend/Session/Redis.php file is already contains some modifications. Please try to apply the changes manually: