Skip to content

Commit 6ce493b

Browse files
committed
Another round
1 parent 6e678ce commit 6ce493b

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

ext/mysqli/mysqli.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
12001200
fci.param_count = 0;
12011201
fci.named_params = NULL;
12021202

1203-
if (ctor_params && zend_hash_num_elements(Z_ARRVAL_P(ctor_params)) != 0) {
1203+
if (ctor_params) {
12041204
if (zend_fcall_info_args(&fci, ctor_params) == FAILURE) {
12051205
ZEND_UNREACHABLE();
12061206
}
@@ -1216,6 +1216,11 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
12161216
zval_ptr_dtor(&retval);
12171217
}
12181218
zend_fcall_info_args_clear(&fci, 1);
1219+
} else if (ctor_params && zend_hash_num_elements(Z_ARRVAL_P(ctor_params)) > 0) {
1220+
zend_argument_error(zend_ce_exception, ERROR_ARG_POS(3),
1221+
"must be empty when the specified class (%s) does not have a constructor",
1222+
ZSTR_VAL(ce->name)
1223+
);
12191224
}
12201225
}
12211226
}

ext/mysqli/tests/mysqli_fetch_object.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,6 @@ Exception: Too few arguments to function mysqli_fetch_object_construct::__constr
147147
NULL
148148
NULL
149149
mysqli_result object is already closed
150-
[0] mysqli_fetch_object(): Argument #3 ($constructor_args) must be of type ?array, string given in %s on line %d
150+
[0] mysqli_fetch_object(): Argument #3 ($constructor_args) must be of type array, string given in %s on line %d
151151
mysqli_fetch_object(): Argument #2 ($class) must be a valid class name, this_class_does_not_exist given
152152
done!

ext/mysqli/tests/mysqli_fetch_object_no_constructor.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ object(mysqli_fetch_object_test)#%d (%d) {
5757
}
5858

5959
Exception with mysqli. Note that at all other places we throws errors but no exceptions unless the error mode has been changed:
60-
Exception: mysqli_fetch_object(): Argument #3 ($constructor_args) must be null when the specified class (mysqli_fetch_object_test) does not have a constructor
60+
Exception: mysqli_fetch_object(): Argument #3 ($constructor_args) must be empty when the specified class (mysqli_fetch_object_test) does not have a constructor
6161

6262
Fatal error with PHP (but no exception!):
6363

ext/pgsql/pgsql.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1933,7 +1933,7 @@ static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, zend_long result_
19331933
fci.param_count = 0;
19341934
fci.named_params = NULL;
19351935

1936-
if (ctor_params && zend_hash_num_elements(Z_ARRVAL_P(ctor_params)) != 0) {
1936+
if (ctor_params) {
19371937
if (zend_fcall_info_args(&fci, ctor_params) == FAILURE) {
19381938
ZEND_UNREACHABLE();
19391939
}
@@ -1951,6 +1951,11 @@ static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, zend_long result_
19511951
if (fci.params) {
19521952
efree(fci.params);
19531953
}
1954+
} else if (ctor_params && zend_hash_num_elements(Z_ARRVAL_P(ctor_params)) > 0) {
1955+
zend_argument_error(zend_ce_exception, 3,
1956+
"must be empty when the specified class (%s) does not have a constructor",
1957+
ZSTR_VAL(ce->name)
1958+
);
19541959
}
19551960
}
19561961
}

0 commit comments

Comments
 (0)