Skip to content

Commit

Permalink
ext/pdo: Throw an exception instead of fatal error if the class is no…
Browse files Browse the repository at this point in the history
…t found (#17528)
  • Loading branch information
Girgias authored Jan 19, 2025
1 parent 9283abc commit 6bd2b8d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ext/pdo/pdo_stmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,7 @@ PHP_METHOD(PDOStatement, fetchAll)
zend_argument_type_error(2, "must be of type string, %s given", zend_zval_value_name(arg2));
RETURN_THROWS();
}
stmt->fetch.cls.ce = zend_fetch_class(Z_STR_P(arg2), ZEND_FETCH_CLASS_AUTO);
stmt->fetch.cls.ce = zend_lookup_class(Z_STR_P(arg2));
if (!stmt->fetch.cls.ce) {
zend_argument_type_error(2, "must be a valid class");
RETURN_THROWS();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
$db = PDOTest::factory();
PDOTest::dropTableIfExists($db, "pdo_fetch_all_class_error_unknown");
?>
--EXPECTF--
--EXPECT--
TypeError: PDOStatement::setFetchMode(): Argument #2 must be a valid class

Fatal error: Class "Unknown" not found in %s on line %d
TypeError: PDOStatement::fetchAll(): Argument #2 must be a valid class

0 comments on commit 6bd2b8d

Please sign in to comment.