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

[Yii2] Fixed unintentional DB connection drop during exception logging #3708

Merged
merged 1 commit into from Nov 10, 2016

Conversation

ivokund
Copy link
Contributor

@ivokund ivokund commented Nov 9, 2016

Fixes #3696

@samdark
Copy link
Collaborator

samdark commented Nov 9, 2016

That's super-weird. Why can't vardumper deal with it?

@samdark
Copy link
Collaborator

samdark commented Nov 9, 2016

But otherwise it looks like it doesn't break anything so @DavertMik, let's merge it.

@DavertMik
Copy link
Member

@samdark that's why #3696 (comment)

please review, maybe there is a nicer way to overcome this error.

@samdark
Copy link
Collaborator

samdark commented Nov 9, 2016

I see no better solution.

@DavertMik
Copy link
Member

Thanks

@DavertMik DavertMik merged commit e62a6f1 into Codeception:2.2 Nov 10, 2016
@ivokund
Copy link
Contributor Author

ivokund commented Nov 10, 2016

@samdark @DavertMik This is actually a simplified proof of concept of one way to close DB connection in Yii2 :)

        $func = function () { 
            throw new \Exception();
        };

        try {
            $func(\Yii::$app->db);
        } catch (\Exception $e) {
            \yii\helpers\VarDumper::export($e);
        }

\Yii::$app->db is present in Exception's trace and thus gets serialized in BaseVarDumper.php:197, which in turn calls __sleep and close in \yii\db\Connection.

This will probably pop up elsewhere as well and needs a proper fix at some point. My first guess would be that \yii\helpers\BaseVarDumper::exportInternal needs a special case handling exceptions that calls __toString() on the Exception rather than tries to serialize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants