Bug #77716 [Opn->Csd]: PDO show warning event the PDO::ERRMODE_EXCEPTION has been set
| From: | nikic@php.net | Date: | Fri, 11 Dec 2020 14:38:21 +0000 |
| Subject: | Bug #77716 [Opn->Csd]: PDO show warning event the PDO::ERRMODE_EXCEPTION has been set | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-231018@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77716&edit=1
ID: 77716
Updated by: nikic@php.net
Reported by: shyandsy at gmail dot com
Summary: PDO show warning event the PDO::ERRMODE_EXCEPTION
has been set
-Status: Open
+Status: Closed
Type: Bug
Package: PDO Core
Operating System: CentOS 7.3.1611
PHP Version: 7.2.16
-Assigned To:
+Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
This issue has been fixed in the meantime.
Previous Comments:
------------------------------------------------------------------------
[2019-09-10 19:45:18] alessandro dot lai85 at gmail dot com
This seems a dupe of https://bugs.php.net/bug.php?id=63812 (which is
WAAAY older, since 5.3!!)
------------------------------------------------------------------------
[2019-03-11 22:52:54] shyandsy at gmail dot com
1. I checked the output of php -m, yeah I m using mysqlnd.
2. This error can be catched by error handler, like following:
```
set_error_handler(function($code, $message, $file, $line) use($log, $config) {
// åç¬å¤çmysql gone away
if(strpos($message, 'server has gone away') !== false){
return false;
}
........
```
3. I checked the source code of mysqlnd, looks you are right
it's just inconsistant to issue a warning if I set the error mode to exception
------------------------------------------------------------------------
[2019-03-11 22:43:16] kalle@php.net
I believe this warning comes from mysqlnd, afair mysqlnd only issues warnings and does not know
about PDO's errormode being set to Exception, hence why it does not honor any ERRMODE_EXCEPTION
value.
Can you confirm you are using mysqlnd?
------------------------------------------------------------------------
[2019-03-09 19:26:07] shyandsy at gmail dot com
u have to set these constant begin with DB_ before u g
the code
------------------------------------------------------------------------
[2019-03-09 18:02:10] danack@php.net
I'm unable to reproduce this error. Please can you check that you are posting the exact script
that shows the error.
Running the code as posted, I get warnings about:
PHP Warning: Use of undefined constant DB_HOSTNAME - assumed 'DB_HOSTNAME' (this will
throw an Error in a future version of PHP) in /var/app/test.php on line 15
Fixing those errors I get a single error, that was caught in the exception block:
SQLSTATE[HY000] [2002] No such file or directory
i.e. the output looks different from what you posted and looks like the correct behaviour.
For example, in your output you have "192.168.216.133" - but you have
"define(DB_HOSTNAME, "");" in the code example.
------------------------------------------------------------------------
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=77716
--
Edit this bug report at https://bugs.php.net/bug.php?id=77716&edit=1