Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ PHP NEWS
. Fixed function JIT ASSIGN_DIM reporting an undefined value or key out of
order, or when the VM does not, on non-array containers. (Jorg Sowa)

- PDO:
. Fixed bug GH-25650 (PDO::query() reports the wrong argument numbers for
FETCH_CLASS constructor arguments). (Tomasz Kowalczyk)

- PDO_Firebird:
. Fixed stack buffer overflow with long connection user names, passwords,
charsets, or roles. (Ilia Alshanetsky)
Expand Down
2 changes: 1 addition & 1 deletion ext/pdo/pdo_stmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1755,7 +1755,7 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a
}
if (Z_TYPE(args[1]) == IS_ARRAY && zend_hash_num_elements(Z_ARRVAL(args[1]))) {
if (cep->constructor == NULL) {
zend_argument_value_error(3, "must be empty when class provided in argument #2 ($class) does not have a constructor");
zend_argument_value_error(constructor_arg_num, "must be empty when class provided in argument #%d ($class) does not have a constructor", arg1_arg_num);
return false;
}
fetch_ctor_args = Z_ARRVAL(args[1]);
Expand Down
6 changes: 6 additions & 0 deletions ext/pdo/tests/pdo_stmt_class_ctor_errors.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ try {
} catch (\Throwable $e) {
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
}
try {
var_dump($db->query('SELECT id, val, val2 from pdo_fetch_all_class_ctor_error', PDO::FETCH_CLASS, 'TestBase', [0]));
} catch (\Throwable $e) {
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
}

?>
--CLEAN--
Expand All @@ -49,3 +54,4 @@ PDOTest::dropTableIfExists($db, "pdo_fetch_all_class_ctor_error");
--EXPECT--
ValueError: PDOStatement::fetchAll(): Argument #3 must be empty when class provided in argument #2 ($class) does not have a constructor
ValueError: PDOStatement::setFetchMode(): Argument #3 must be empty when class provided in argument #2 ($class) does not have a constructor
ValueError: PDO::query(): Argument #4 must be empty when class provided in argument #3 ($class) does not have a constructor
Loading