-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Bug #64705 errorInfo property of PDOException is null when PDO::__construct() fails #1561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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. |
@@ -38,6 +38,51 @@ | |||
|
|||
static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, long attr, zval *value TSRMLS_DC); | |||
|
|||
PDO_API zval *pdo_throw_exception_ex(zend_class_entry *exception_ce, pdo_error_type *pdo_err, long code TSRMLS_DC, const char *format, ...) /* {{{ */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: