#50728 [NEW]: All PDOExceptions hardcode 'code' property to 0
| From: | joey@php.net | Date: | Tue, 12 Jan 2010 03:36:34 +0000 |
| Subject: | #50728 [NEW]: All PDOExceptions hardcode 'code' property to 0 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-146566@lists.php.net to get a copy of this message | ||
From: joey@php.net
Operating system: All
PHP version: 5.3.2RC1
PHP Bug Type: PDO related
Bug description: All PDOExceptions hardcode 'code' property to 0
Description:
------------
From user report in ##PHP/freenode:
Each of the PDO drivers explicitly sets the 'code' property of their
PDOException to 0, instead of passing along the driver-specific error code.
I will attach is a set of proposed patches (against HEAD and 5.3.2 branch
as of 2009-01-11) that I believe would fix this for each driver (although
I'm guessing on the dblib - it used a significantly different model by
storing the error state in DBLIB_G).
The example is from the sqlite driver - you can see that an error #14 gets
stored in the 'message', but doesn't get passed to the 'code'.
Reproduce code:
---------------
try {
$a = new PDO("sqlite:/this/path/should/not/exist.db");
} catch (PDOException $e) {
var_dump($e->getCode());
}
Expected result:
----------------
int(14)
Actual result:
--------------
int(0)
--
Edit bug report at http://bugs.php.net/?id=50728&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50728&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50728&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50728&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=50728&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50728&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=50728&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=50728&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=50728&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=50728&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=50728&r=support
Expected behavior: http://bugs.php.net/fix.php?id=50728&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=50728&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=50728&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=50728&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50728&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=50728&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=50728&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=50728&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=50728&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=50728&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=50728&r=mysqlcfg