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

Disable PHP Warning #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Maxim-Mazurok
Copy link
Contributor

I'm getting PHP Warning:

PHP Warning:  Error while sending QUERY packet. PID=23374 in vendor/legow/reconnecting-pdo/src/ReconnectingPDO.php on line 325
PHP Stack trace:
PHP   1. {main}() src/worker/db_test.php:0
PHP   2. Doctrine\DBAL\Connection->ping() src/worker/db_test.php:46
PHP   3. Doctrine\DBAL\Connection->query() vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:1671
PHP   4. LegoW\ReconnectingPDO\ReconnectingPDO->query() vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:1010
PHP   5. LegoW\ReconnectingPDO\ReconnectingPDO->call() vendor/legow/reconnecting-pdo/src/ReconnectingPDO.php:287
PHP   6. LegoW\ReconnectingPDO\ReconnectingPDO->ping() vendor/legow/reconnecting-pdo/src/ReconnectingPDO.php:109
PHP   7. PDO->query() vendor/legow/reconnecting-pdo/src/ReconnectingPDO.php:325

I've tried to catch it with set_error_handler with no luck.

So, let's mute it by adding @: @$this->connection->query('SELECT 1');

@Maxim-Mazurok
Copy link
Contributor Author

@adamturcsan can you approve, please?

@adamturcsan
Copy link
Owner

Sorry for the late response.
Could you please describe the environment and the context of the phenomena?
I'd like to recommend using Exception style error handling (https://www.php.net/manual/en/pdo.error-handling.php) instead. Not just because then it should throw a warning but because that's the base of the reconnecting mechanism. It should be set analogous to the original PDO.

Does it solve your problem?

Sorry, but I'm not exactly a fan of the @ style solutions, so I'd like to understand the issue first.

@Maxim-Mazurok
Copy link
Contributor Author

Thanks for your feedback!

I'm using PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, but it isn't helping.
It's a bug in PDO that causes both warning and exception to be triggered.
You can find a more detailed explanation here: PDO::ERRMODE_EXCEPTION doesn't suppress warning
So, as much as I hate using @, I couldn't find any better solution.
Currently, I ended up extending your class and overriding the ping method, which is also not a great solution, because if you will update your ping method - I will have to update my method as well.

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.

2 participants