Skip to content

Commit 6bd2b8d

Browse files
authored
ext/pdo: Throw an exception instead of fatal error if the class is not found (#17528)
1 parent 9283abc commit 6bd2b8d

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

ext/pdo/pdo_stmt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,7 @@ PHP_METHOD(PDOStatement, fetchAll)
12311231
zend_argument_type_error(2, "must be of type string, %s given", zend_zval_value_name(arg2));
12321232
RETURN_THROWS();
12331233
}
1234-
stmt->fetch.cls.ce = zend_fetch_class(Z_STR_P(arg2), ZEND_FETCH_CLASS_AUTO);
1234+
stmt->fetch.cls.ce = zend_lookup_class(Z_STR_P(arg2));
12351235
if (!stmt->fetch.cls.ce) {
12361236
zend_argument_type_error(2, "must be a valid class");
12371237
RETURN_THROWS();

ext/pdo/tests/pdo_stmt_class_ctor_errors_cannot_find_class.phpt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
3939
$db = PDOTest::factory();
4040
PDOTest::dropTableIfExists($db, "pdo_fetch_all_class_error_unknown");
4141
?>
42-
--EXPECTF--
42+
--EXPECT--
4343
TypeError: PDOStatement::setFetchMode(): Argument #2 must be a valid class
44-
45-
Fatal error: Class "Unknown" not found in %s on line %d
44+
TypeError: PDOStatement::fetchAll(): Argument #2 must be a valid class

0 commit comments

Comments
 (0)