Bug #63812 [Com]: PDO Triggers Warning(s) Regardless of Error Handling Strategy

From: Date: Fri, 09 Nov 2018 13:17:32 +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-217881@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: jferrer at data-solutions 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: This bug is a ******* joke I don't understand how something like this is still not fixed in php 7.0.3 This is how i "fixed" it: // Convert NOTICE, WARNING, ... in Exceptions $convert_error_to_exception = function ($level, $message, $file, $line, $context=null){ throw new ErrorException($message, 0, $level, $file, $line); }; set_error_handler($convert_error_to_exception); I convert Warnings in ErrorException which makes them catchable Previous Comments: ------------------------------------------------------------------------ [2017-04-20 15:38:05] justpusher at gmail dot com We faced this bug too after upgrading our servers to PHP 5.6.30. Ubuntu 16.04.2 LTS The test script given in the bug description reproduces the bug. ------------------------------------------------------------------------ [2016-06-15 07:57:47] gaobin3243 at 126 dot com I have the same problem, regardless PDO::ERRMODE_EXCEPTION I sometimes get warnings or both warnings and the pdoexception equivalent at the same time (!!!). ------------------------------------------------------------------------ [2016-02-23 09:39:41] oxygenus at gmail dot com Still present in PHP 7. ------------------------------------------------------------------------ [2015-06-23 23:16:28] klenium2 at gmail dot com 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. ------------------------------------------------------------------------ [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. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=63812 -- Edit this bug report at https://bugs.php.net/bug.php?id=63812&edit=1

« previous php.bugs (#217881) next »