codeigniter4 / CodeIgniter4

Open Source PHP Framework (originally from EllisLab)
https://codeigniter.com/
MIT License
5.4k stars 1.9k forks source link

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

Closed JasonSanYe closed 2 years ago

JasonSanYe commented 2 years ago

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

kenjis commented 2 years ago

Please write in English.

paulbalandan commented 2 years ago

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

hurtsky commented 2 years ago

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

kenjis commented 2 years ago

@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];