yii2-redis
yii2-redis copied to clipboard
在php7.1版本时readSession 当redis返回null时 不是字符串报错
| Yii vesion 2.0.15 | PHP version 7.1 | Operating system centos redis:4.0.2 `/** * Session read handler. * Do not call this method directly. * @param string $id session ID * @return string the session data */ public function readSession($id) { $data = $this->redis->executeCommand('GET', [$this->calculateKey($id)]);
return $data === false ? '' : $data;
}`
$data=null时 就不全等于false了,返回的是null session_start(): Failed to read session data: user (path: ) php7.1里readSession必须返回字符串
can you show a stack trace of the exception?
can you show a stack trace of the exception?
Confirmed, I see this problem on the Cache component too, where getValue() returns NULL instead of false when checking for a key existence.
Redis returns "-1" when a key is not found, and this fall into this case:
https://github.com/yiisoft/yii2-redis/blob/98fc1c53385736343e67963826ee8fa420ee5e21/src/Connection.php#L740-L743