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

Prevents warning when closing connection #32

Closed
wants to merge 1 commit into from

Conversation

marcioAlmada
Copy link
Contributor

Prevents warning when closing connection:

fclose(): supplied resource is not a valid stream resource in ./vendor/amphp/mysql/lib/Processor.php:821

Otherwise aerys application gets unusable with error handlers like:

set_error_handler(function($errno, $errstr, $file, $line) {
    throw new \Exception("{$errstr} in {$file}:{$line}", $errno);
});

```
fclose(): supplied resource is not a valid stream resource in ./vendor/amphp/mysql/lib/Processor.php:821
```
@mention-bot
Copy link

@marcioAlmada, thanks for your PR! By analyzing the history of the files in this pull request, we identified @bwoebi to be a potential reviewer.

@marcioAlmada
Copy link
Contributor Author

Funny thing is that this bug occurs within aerys but I can't reproduce in isolation 🤔

@bwoebi
Copy link
Member

bwoebi commented Apr 18, 2017

This is why one does use an error handler like:

set_error_handler(function($errno, $errstr, $file, $line) {
    if (error_reporting()) { // because the @-operator will set error_reporting() === 0
        throw new \Exception("{$errstr} in {$file}:{$line}", $errno);
    }
});

An if (is_resource()) check will only catch one of the potentially warning conditions. Hence it's better to not merge this and just have your error handler handle it properly.

@bwoebi bwoebi closed this Apr 18, 2017
@marcioAlmada
Copy link
Contributor Author

marcioAlmada commented Apr 18, 2017

It concerns me to see untreated warnings in the logs. But I think patching the error handler makes more sense than patching amphp/mysql.

👍

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

Successfully merging this pull request may close these issues.

3 participants