Bug #63812 [Com]: PDO Triggers Warning(s) Regardless of Error Handling Strategy
| From: | klenium2 at gmail dot com | Date: | Tue, 23 Jun 2015 23:16:29 +0000 |
| Subject: | Bug #63812 [Com]: PDO Triggers Warning(s) Regardless of Error Handling Strategy | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-193824@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63812&edit=1
ID: 63812
Comment by: klenium2 at gmail dot com
Reported by: sergey at shymko dot net
Summary: PDO Triggers Warning(s) Regardless of Error Handling
Strategy
Status: Open
Type: Bug
Package: PDO MySQL
Operating System: Linux
PHP Version: 5.3.19
Block user comment: N
Private report: N
New Comment:
Similar problem:
try { new PDO(
"mysql:dbname=test;host=notalocalhost",
$user, $pass,
[PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT]
); }
catch (PDOException $e) { die("msg: ".$e->getMessage()); }
Result:
Warning: PDO::__construct(): in C:\file.php on line 2
msg: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Nincs ilyen ismert
állomás.
Previous Comments:
------------------------------------------------------------------------
[2015-02-11 13:20:32] oxygenus at gmail dot com
PHP 5.6.5 (cli) (built: Jan 21 2015 17:50:29)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
with Xdebug v2.2.7, Copyright (c) 2002-2015, by Derick Rethans
set_error_handler is ignored and has no effect.
Also, as others have commented, the PDO exception mode is also ignored.
The warning is sent to php://stdout no matter what, even if making sure the PDO instance is
destroyed and disconnected.
Apparently, the warning is sent to php://stdout during garbage collection.
It makes JSONRPC servers and other stuff impossible to use.
------------------------------------------------------------------------
[2015-01-20 03:10:06] nospampls at nospam dot org
I have the same problem, regardless PDO::ERRMODE_EXCEPTION I sometimes get warnings or both warnings
and the pdoexception equivalent at the same time (!!!).
please fix
------------------------------------------------------------------------
[2013-05-03 05:09:30] fog at yandex dot ru
There is another similar problem, sometimes connection fails with message:
Warning: PDO::__construct(): MySQL server has gone away in [...file_path...] on line N
It happens despiting that PDO::ATTR_ERRMODE is set to PDO::ERRMODE_EXCEPTION
------------------------------------------------------------------------
[2012-12-20 05:34:45] sergey at shymko dot net
Relates to https://bugs.php.net/bug.php?id=63546
------------------------------------------------------------------------
[2012-12-20 05:25:22] sergey at shymko dot net
Description:
------------
PDO triggers warning(s) regardless of the chosen error handling strategy
http://php.net/manual/en/pdo.error-handling.php
Environment:
- mysql Ver 14.14 Distrib 5.5.22, for Linux (x86_64) using EditLine wrapper
Test script:
---------------
<?php
$adapter = new PDO('mysql:host=localhost;db_name=test', 'root', '');
$adapter->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
assert($adapter->getAttribute(PDO::ATTR_ERRMODE) === PDO::ERRMODE_EXCEPTION);
$waitTimeout = 1;
$adapter->exec("SET @@session.wait_timeout = {$waitTimeout}");
$statement = $adapter->query('SELECT @@session.wait_timeout');
assert($statement->fetchColumn() == $waitTimeout);
/**
* Ensure 'MySQL server has gone away' conditions are met
*/
sleep($waitTimeout + 1);
$adapter->query('SELECT 1');
Expected result:
----------------
- PDOException with message 'SQLSTATE[HY000]: General error: 2006 MySQL server
has gone away'
- No warnings (because of the chosen PDO error handling strategy)
Actual result:
--------------
1. When connection type is TCP/IP:
1. Warning: PDO::query() [pdo.query]: MySQL server has gone away
2. Warning: PDO::query() [pdo.query]: Error reading result set's header
1'. When connection type is Unix socket:
1. Warning: Error while sending QUERY packet. PID=18586
2. PDOException with message 'SQLSTATE[HY000]: General error: 2006 MySQL server
has gone away'
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63812&edit=1