Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
hkui opened this issue Nov 15, 2018 · 3 comments
Open
Labels
status:ready for adoption Feel free to implement this issue. type:bug Bug

Comments

@hkui
Copy link

hkui commented Nov 15, 2018

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

@cebe
Copy link
Member

cebe commented Nov 15, 2018

can you show a stack trace of the exception?

@hkui
Copy link
Author

hkui commented Nov 15, 2018

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

@machour
Copy link
Member

machour commented May 4, 2019

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:

case '$': // Bulk replies
if ($line == '-1') {
return null;
}

@machour machour added status:ready for adoption Feel free to implement this issue. type:bug Bug labels May 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready for adoption Feel free to implement this issue. type:bug Bug
Projects
None yet
Development

No branches or pull requests

3 participants