yii2-redis icon indicating copy to clipboard operation
yii2-redis copied to clipboard

在php7.1版本时readSession 当redis返回null时 不是字符串报错

Open hkui opened this issue 6 years ago • 3 comments

| 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必须返回字符串

hkui avatar Nov 15 '18 09:11 hkui

can you show a stack trace of the exception?

cebe avatar Nov 15 '18 09:11 cebe

can you show a stack trace of the exception? yii-redis-bug

hkui avatar Nov 15 '18 10:11 hkui

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

machour avatar May 04 '19 22:05 machour