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

Bug in \yii\redis\Connection (it closes connection after serialize) #13084

Closed
IStranger opened this issue Nov 28, 2016 · 1 comment
Closed

Bug in \yii\redis\Connection (it closes connection after serialize) #13084

IStranger opened this issue Nov 28, 2016 · 1 comment

Comments

@IStranger
Copy link

IStranger commented Nov 28, 2016

What steps will reproduce the problem?

Enable Redis cache in config:

'components' => [
    'cache' => [
        'class' => 'yii\redis\Cache',
    ],
],

Then execute:

error_reporting(E_ERROR);

Yii::$app->cache->set('someKey', 'someValue');

$print = VarDumper::export(Yii::$app->cache);        // This will close redis connection
// $print = serialize(Yii::$app->cache);                // This will close redis connection
// $print = var_export(Yii::$app->cache, true);         // This won't close redis connection

$cachedValue = Yii::$app->cache->get('someKey');        // This won't work at closed redis connection:

//   error_reporting(E_ERROR) :: >> Database Exception – yii\db\Exception::: Failed to read from socket. Redis command was: GET keyPrefix:someKey
//   error_reporting(E_ALL)   :: >> PHP Warning – yii\base\ErrorException::: fwrite() expects parameter 1 to be resource, null given

What is the expected result?

Redis connection closes connection at serializing. This is normal behavior (see \yii\redis\Connection::__sleep).
However after serializing cache component won't work. I think redis connection should be restored.

Additional info

Q A
Yii version 2.0.9
PHP version 5.5.34
Operating system Mac OS X 10.11.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants