Skip to content

Commit 005d04a

Browse files
authored
zend_call_function: emit function deprecation before setting up call frame (php#20264)
1 parent b3d8465 commit 005d04a

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Deprecated function notice promoted to exception within zend_call_function()
3+
--FILE--
4+
<?php
5+
6+
#[Deprecated]
7+
function foo(string $v) {
8+
return $v . '!';
9+
}
10+
11+
set_error_handler(function ($number, $message) {
12+
throw new Exception($message);
13+
});
14+
15+
$a = array_map(foo(...), ['Hello', 'World']);
16+
var_dump($a);
17+
18+
?>
19+
--EXPECTF--
20+
Fatal error: Uncaught Exception: Function foo() is deprecated in %s:%d
21+
Stack trace:
22+
#0 [internal function]: {closure:%s:%d}(16384, 'Function foo() ...', '%s', %d)
23+
#1 %s(%d): array_map(Object(Closure), Array)
24+
#2 {main}
25+
thrown in %s on line %d

Zend/zend_execute_API.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -862,18 +862,17 @@ zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_
862862
call_info = ZEND_CALL_TOP_FUNCTION | ZEND_CALL_DYNAMIC | ZEND_CALL_HAS_THIS;
863863
}
864864

865-
call = zend_vm_stack_push_call_frame(call_info,
866-
func, fci->param_count, object_or_called_scope);
867-
868865
if (UNEXPECTED(func->common.fn_flags & ZEND_ACC_DEPRECATED)) {
869866
zend_deprecated_function(func);
870867

871868
if (UNEXPECTED(EG(exception))) {
872-
zend_vm_stack_free_call_frame(call);
873869
return SUCCESS;
874870
}
875871
}
876872

873+
call = zend_vm_stack_push_call_frame(call_info,
874+
func, fci->param_count, object_or_called_scope);
875+
877876
for (uint32_t i = 0; i < fci->param_count; i++) {
878877
zval *param = ZEND_CALL_ARG(call, i+1);
879878
zval *arg = &fci->params[i];

0 commit comments

Comments
 (0)