From:
Operating system: Windows XP SP3
PHP version: 5.3.3
Package: PDO related
Bug Type: Bug
Bug description:warning catch by php before PDOException
Description:
------------
I catch all PHP error to do my own behavior error but with this case (test
out of the other code), when server is down, PHP catch an error (here a
Warning) and only after catch a PDOException.
I think that an error because error message or same in two cases and too,
if an Exception is launch, why do an PHP error ?
Test script:
---------------
<?php
$arrDriverOption = array();
$arrDriverOption[ \PDO::MYSQL_ATTR_INIT_COMMAND ] = 'SET NAMES UTF8';
$arrDriverOption[ \PDO::ATTR_TIMEOUT ] = 2;
new \PDO('mysql:host=localhost;port=3307;dbname=mydb', 'root', 'r',
$arrDriverOption);
Expected result:
----------------
Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[HY000] [2002] Une tentative de connexion a échoué car le parti
connecté n'a pas répondu convenablement au-delà d'une certaine durée ou
une connexion établie a échoué car l'hôte de connexion n'a pas
répondu. ' in C:\Serveur\Apache2\htdocs\test\__web\index2.php:5 Stack
trace: #0 C:\Serveur\Apache2\htdocs\test\__web\index2.php(5):
PDO->__construct('mysql:host=loca...', 'root', 'r', Array) #1 {main} thrown
in C:\Serveur\Apache2\htdocs\test\__web\index2.php on line 5
Actual result:
--------------
Warning: PDO::__construct() [pdo.--construct]: [2002] Une tentative de
connexion a échoué car le parti connecté n'a pa (trying to connect via
tcp://localhost:3307) in C:\Serveur\Apache2\htdocs\test\__web\index2.php on
line 5
Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[HY000] [2002] Une tentative de connexion a échoué car le parti
connecté n'a pas répondu convenablement au-delà d'une certaine durée ou
une connexion établie a échoué car l'hôte de connexion n'a pas
répondu. ' in C:\Serveur\Apache2\htdocs\test\__web\index2.php:5 Stack
trace: #0 C:\Serveur\Apache2\htdocs\test\__web\index2.php(5):
PDO->__construct('mysql:host=loca...', 'root', 'r', Array) #1 {main} thrown
in C:\Serveur\Apache2\htdocs\test\__web\index2.php on line 5
--
Edit bug report at http://bugs.php.net/bug.php?id=52414&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=52414&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=52414&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=52414&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=52414&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=52414&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=52414&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=52414&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=52414&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=52414&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=52414&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=52414&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=52414&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=52414&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=52414&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52414&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52414&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=52414&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=52414&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=52414&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=52414&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=52414&r=mysqlcfg