Skip to content

Commit 99a7173

Browse files
committed
Make invalid user callable throw a type error
1 parent 595a0b8 commit 99a7173

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

ext/pdo/pdo_stmt.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -689,12 +689,12 @@ static int make_callable_ex(pdo_stmt_t *stmt, zval *callable, zend_fcall_info *
689689

690690
if (zend_fcall_info_init(callable, 0, fci, fcc, NULL, &is_callable_error) == FAILURE) {
691691
if (is_callable_error) {
692-
pdo_raise_impl_error(stmt->dbh, stmt, "HY000", is_callable_error);
692+
zend_type_error("%s", is_callable_error);
693693
efree(is_callable_error);
694694
} else {
695-
pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "user-supplied function must be a valid callback");
695+
zend_type_error("user-supplied function must be a valid callback");
696696
}
697-
return 0;
697+
return false;
698698
}
699699
if (is_callable_error) {
700700
/* Possible error message */
@@ -704,20 +704,20 @@ static int make_callable_ex(pdo_stmt_t *stmt, zval *callable, zend_fcall_info *
704704
fci->param_count = num_args; /* probably less */
705705
fci->params = safe_emalloc(sizeof(zval), num_args, 0);
706706

707-
return 1;
707+
return true;
708708
}
709709
/* }}} */
710710

711-
static int do_fetch_func_prepare(pdo_stmt_t *stmt) /* {{{ */
711+
static bool do_fetch_func_prepare(pdo_stmt_t *stmt) /* {{{ */
712712
{
713713
zend_fcall_info *fci = &stmt->fetch.cls.fci;
714714
zend_fcall_info_cache *fcc = &stmt->fetch.cls.fcc;
715715

716716
if (!make_callable_ex(stmt, &stmt->fetch.func.function, fci, fcc, stmt->column_count)) {
717-
return 0;
717+
return false;
718718
} else {
719719
stmt->fetch.func.values = safe_emalloc(sizeof(zval), stmt->column_count, 0);
720-
return 1;
720+
return true;
721721
}
722722
}
723723
/* }}} */
@@ -1338,8 +1338,8 @@ PHP_METHOD(PDOStatement, fetchAll)
13381338
}
13391339
/* TODO Check it is a callable? */
13401340
ZVAL_COPY_VALUE(&stmt->fetch.func.function, arg2);
1341-
if (do_fetch_func_prepare(stmt) == 0) {
1342-
error = 1;
1341+
if (do_fetch_func_prepare(stmt) == false) {
1342+
RETURN_THROWS();
13431343
}
13441344
break;
13451345

0 commit comments

Comments
 (0)