CodeIgniter4 icon indicating copy to clipboard operation
CodeIgniter4 copied to clipboard

Bug: Redis::connect(): Passing null to parameter #3 ($timeout) of type float is deprecated

Open JasonSanYe opened this issue 2 years ago • 4 comments

PHP Version

8.1

CodeIgniter4 Version

4.2.6

CodeIgniter4 Installation Method

Composer (as dependency to an existing project)

Which operating systems have you tested for this bug?

macOS

Which server did you use?

fpm-fcgi

Database

No response

What happened?

将session 设置redis

php7.4正常

php8.1报错:Redis::connect(): Passing null to parameter #3 ($timeout) of type float is deprecated

image

Steps to Reproduce

将session 设置redis

php8.1 下

Expected Output

将session 设置redis

php8.1 下

Anything else?

No response

JasonSanYe avatar Sep 08 '22 03:09 JasonSanYe

Please write in English.

kenjis avatar Sep 08 '22 03:09 kenjis

Can you show your $sessionSavePath value in Config\App?

paulbalandan avatar Sep 08 '22 03:09 paulbalandan

I also having this problem while testing with redis. Im using .env with app.sessionSavePath = 'tcp://127.0.0.1:6379' with php8.1. on php7.4 no ErrorException

hurtsky avatar Sep 11 '22 11:09 hurtsky

@hurtsky Try:

--- a/system/Session/Handlers/RedisHandler.php
+++ b/system/Session/Handlers/RedisHandler.php
@@ -78,7 +78,7 @@ class RedisHandler extends BaseHandler
                 'port'     => empty($matches[2]) ? null : $matches[2],
                 'password' => preg_match('#auth=([^\s&]+)#', $matches[3], $match) ? $match[1] : null,
                 'database' => preg_match('#database=(\d+)#', $matches[3], $match) ? (int) $match[1] : null,
-                'timeout'  => preg_match('#timeout=(\d+\.\d+)#', $matches[3], $match) ? (float) $match[1] : null,
+                'timeout'  => preg_match('#timeout=(\d+\.\d+)#', $matches[3], $match) ? (float) $match[1] : 0.0,
             ];
 
             preg_match('#prefix=([^\s&]+)#', $matches[3], $match) && $this->keyPrefix = $match[1];

kenjis avatar Sep 11 '22 12:09 kenjis