Bug #64705 errorInfo property of PDOException is null when PDO::__construct() fails#1561
Bug #64705 errorInfo property of PDOException is null when PDO::__construct() fails#1561kalaspuffar wants to merge 26 commits intophp:PHP-5.6from
Conversation
|
After reading the comments closely on the comments on the document page I suggest we make a document change to be more explicit and change what code is. An exception has a code int that is populated from the internal error code from the different PDO drivers. But the SQLState (5 char) should not override this in the PDOException implementation. This makes the class hard to use and does not work with already written tests. So my suggestion is that we keep the code int and return the errorInfo structure as normal with the SQLState included. Exception::errorInfo = array(3) { So index 0 is the state, index 1 is the driver code and lastly index 2 is the message. Have a value being both a String and Int at the same time will confuse unnecessarily. |
ext/pdo/pdo_dbh.c
Outdated
There was a problem hiding this comment.
Every time pdo_throw_exception_ex is ever called exception_ce parameter is always php_pdo_get_exception(). Since this is clearly a PDO-specific function, maybe this parameter should be eliminated and this function should call php_pdo_get_exception() instead?
There was a problem hiding this comment.
Well, zend_throw_exception_ex was extendable so I wanted to keep that option, but your right this is possibly not required or wanted in a library where the purpose is to unify driver interaction.
edad9a5 to
c859a90
Compare
c1d792e to
d44d2c1
Compare
d44d2c1 to
aa7ce79
Compare
71d229a to
2b63160
Compare
…p entry filename is "/"
Doing a less intrusive variant of the PHP 7.0 fix for 5.6.
… non-existent constant)
Actually, this only be fixed if php uses mysqlnd
…paramater default value)
… that will populate the errorInfo property of the PDOException class.
…ll when PDO::__construct() fails.
…d_throw_exception_ex.
…xception for pgsql databases.
… because we don't allow extending in pdo modules.
|
Since this targets a security fix only branch, and since a patch against a supported branch would have to be different, I'm closing this PR. Please take this action as encouragement to open a clean PR against a supported branch, in addition please leave whitespace changes out of any subsequent PR, and make those as separate PR's. |
|
@krakjoe Thank you for the feedback. |
Changes:
Tested with: