fix: 修复在 php8 环境下 session 使用 Redis 时不兼容的问题

This commit is contained in:
F4nniu
2024-06-15 23:44:09 +08:00
parent c79fdd579e
commit 01392c2250

View File

@@ -42,6 +42,7 @@ class Redis extends SessionHandler
* @return bool
* @throws Exception
*/
#[\ReturnTypeWillChange]
public function open($savePath, $sessName)
{
// 检测php环境
@@ -69,6 +70,7 @@ class Redis extends SessionHandler
* 关闭Session
* @access public
*/
#[\ReturnTypeWillChange]
public function close()
{
$this->gc(ini_get('session.gc_maxlifetime'));
@@ -83,6 +85,7 @@ class Redis extends SessionHandler
* @param string $sessID
* @return string
*/
#[\ReturnTypeWillChange]
public function read($sessID)
{
return (string) $this->handler->get($this->config['session_name'] . $sessID);
@@ -92,9 +95,10 @@ class Redis extends SessionHandler
* 写入Session
* @access public
* @param string $sessID
* @param String $sessData
* @param string $sessData
* @return bool
*/
#[\ReturnTypeWillChange]
public function write($sessID, $sessData)
{
if ($this->config['expire'] > 0) {
@@ -110,6 +114,7 @@ class Redis extends SessionHandler
* @param string $sessID
* @return bool
*/
#[\ReturnTypeWillChange]
public function destroy($sessID)
{
return $this->handler->del($this->config['session_name'] . $sessID) > 0;
@@ -121,6 +126,7 @@ class Redis extends SessionHandler
* @param string $sessMaxLifeTime
* @return bool
*/
#[\ReturnTypeWillChange]
public function gc($sessMaxLifeTime)
{
return true;