Uh oh!
There was an error while loading. Please reload this page.
PDO Unconditional errors - #6212
Conversation
nikic
left a comment
There was a problem hiding this comment.
Can you please apply the bug fix separately (together with corresponding test changes)?
Uh oh!
There was an error while loading. Please reload this page.
nikic
commented
Sep 25, 2020
And please also apply at least "Inverse logic in do_fetch() to reduce a level of indentation" separately, as the indentation changes makes it hard to understand the diff. |
19bc7ab to
1f276daCompareebdc73b to
9d79ad6CompareUh oh!
There was an error while loading. Please reload this page.
b03e59e to
32b0b47CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Girgias
commented
Sep 28, 2020
Pushing review changed before the ZPP variadic revert which I'm doing now |
5e67d6d to
0ae6ecbComparepdo_stmt_verify_mode() never returns FAILURE (aka -1) and thus this path was never hit
Promote a couple of confirmed cases to unconditional error Fix error messages
Promote a couple of confirmed cases to unconditional error Fix error messages
… the ODBC driver And ammend PDO::quote() test to take into account drivers which do not support the feature
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
I'm not confident it can't fail, e.g. >&- is used.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
So this happens if you use an out of bounds parameter number? I think generally it would make sense for things like this to throw, but we need to be careful that native & emulated prepared statements have the same behavior. I don't know whether both go through this codepath.
There was a problem hiding this comment.
I think those trigger if the param name/number is not present. I would imagine they both go through this code path as this is something internal to PDO which is not exposed, as all PDO bind param/value methods go through this. Or do emulated prepared statements somehow override the PDO methods?
Indentation Error message Use variadic number position for pdo_stmt_setup_fetch_mode() param cehcks Use values from *args directly instead of preassigning them in pdo_stmt_setup_fetch_mode() Drop todo comment
0ae6ecb to
e4a13d0CompareUh oh!
There was an error while loading. Please reload this page.
Indent (again) Drop unnecessary cehck Improve title + SKIPIF for PDO SQLite test
| ); | ||
| PDO_HANDLE_DBH_ERR(); | ||
| RETURN_FALSE; | ||
| zend_type_error("PDO::ATTR_STATEMENT_CLASS ctor_args must be ?array, %s given", |
There was a problem hiding this comment.
| zend_type_error("PDO::ATTR_STATEMENT_CLASS ctor_args must be ?array, %s given", | |
| zend_type_error("PDO::ATTR_STATEMENT_CLASS ctor_args must be of type ?array, %s given", |
| "ctor_args must be an array" | ||
| ); | ||
| PDO_HANDLE_DBH_ERR(); | ||
| zend_type_error("PDO::ATTR_STATEMENT_CLASS ctor_args must be ?array, %s given", |
There was a problem hiding this comment.
| zend_type_error("PDO::ATTR_STATEMENT_CLASS ctor_args must be ?array, %s given", | |
| zend_type_error("PDO::ATTR_STATEMENT_CLASS ctor_args must be of type ?array, %s given", |
| /* Figure out correct class */ | ||
| if (arg2) { | ||
| if (Z_TYPE_P(arg2) != IS_STRING) { | ||
| zend_argument_type_error(2, "must be string, %s given", zend_zval_type_name(arg2)); |
There was a problem hiding this comment.
| zend_argument_type_error(2, "must be string, %s given", zend_zval_type_name(arg2)); | |
| zend_argument_type_error(2, "must be of type string, %s given", zend_zval_type_name(arg2)); |
| if (arg2) { | ||
| // Reuse convert_to_long(arg2); ? | ||
| if (Z_TYPE_P(arg2) != IS_LONG) { | ||
| zend_argument_type_error(2, "must be int, %s given", zend_zval_type_name(arg2)); |
There was a problem hiding this comment.
| zend_argument_type_error(2, "must be int, %s given", zend_zval_type_name(arg2)); | |
| zend_argument_type_error(2, "must be of type int, %s given", zend_zval_type_name(arg2)); |
| return false; | ||
| } | ||
| if (Z_TYPE(args[0]) != IS_LONG) { | ||
| zend_argument_type_error(arg1_arg_num, "must be int, %s given", zend_zval_type_name(&args[0])); |
There was a problem hiding this comment.
| zend_argument_type_error(arg1_arg_num, "must be int, %s given", zend_zval_type_name(&args[0])); | |
| zend_argument_type_error(arg1_arg_num, "must be of type int, %s given", zend_zval_type_name(&args[0])); |
| return false; | ||
| } | ||
| if (Z_TYPE(args[0]) != IS_STRING) { | ||
| zend_argument_type_error(arg1_arg_num, "must be string, %s given", zend_zval_type_name(&args[0])); |
There was a problem hiding this comment.
| zend_argument_type_error(arg1_arg_num, "must be string, %s given", zend_zval_type_name(&args[0])); | |
| zend_argument_type_error(arg1_arg_num, "must be of type string, %s given", zend_zval_type_name(&args[0])); |
| retval = FAILURE; | ||
| } else if (Z_TYPE(args[1]) == IS_ARRAY && zend_hash_num_elements(Z_ARRVAL(args[1]))) { | ||
| ZVAL_ARR(&stmt->fetch.cls.ctor_args, zend_array_dup(Z_ARRVAL(args[1]))); | ||
| zend_argument_type_error(constructor_arg_num, "must be ?array, %s given", |
There was a problem hiding this comment.
| zend_argument_type_error(constructor_arg_num, "must be ?array, %s given", | |
| zend_argument_type_error(constructor_arg_num, "must be of type ?array, %s given", |
| if (SUCCESS == retval) { | ||
| ZVAL_COPY(&stmt->fetch.into, &args[0]); | ||
| if (Z_TYPE(args[0]) != IS_OBJECT) { | ||
| zend_argument_type_error(arg1_arg_num, "must be object, %s given", zend_zval_type_name(&args[0])); |
There was a problem hiding this comment.
| zend_argument_type_error(arg1_arg_num, "must be object, %s given", zend_zval_type_name(&args[0])); | |
| zend_argument_type_error(arg1_arg_num, "must be object, %s given", zend_zval_type_name(&args[0])); |
| zend_argument_type_error(arg1_arg_num, "must be object, %s given", zend_zval_type_name(&args[0])); | |
| zend_argument_type_error(arg1_arg_num, "must be of type object, %s given", zend_zval_type_name(&args[0])); |
| zval *args = NULL; | ||
| uint32_t num_args = 0; | ||
| /* Support null for constructor arguments for BC */ |
| if (Z_TYPE_P(value) != IS_LONG && Z_TYPE_P(value) != IS_STRING && Z_TYPE_P(value) != IS_FALSE && Z_TYPE_P(value) != IS_TRUE) { \ | ||
| pdo_raise_impl_error(dbh, NULL, "HY000", "attribute value must be an integer"); \ | ||
| PDO_HANDLE_DBH_ERR(); \ | ||
| zend_type_error("Attribute value must be int for selected attribute, %s given", zend_zval_type_name(value)); \ |
There was a problem hiding this comment.
| zend_type_error("Attribute value must be int for selected attribute, %s given", zend_zval_type_name(value)); \ | |
| zend_type_error("Attribute value must be of type int for selected attribute, %s given", zend_zval_type_name(value)); \ |
A couple of unrelated refactoring changes that I made should be able to land on their own if it makes the PR too noisy.
Used only PDO MySQL for tests so hopefully not too many more drivers complain.