Skip to content

Commit c1da0b5

Browse files
committed
Drop check for exception type and add tests
1 parent f333f71 commit c1da0b5

6 files changed

+98
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Silencing an internal function supplementary argument throwing an Exception
3+
--FILE--
4+
<?php
5+
6+
function foo() {
7+
throw new Exception();
8+
return 1;
9+
}
10+
11+
$var = error_get_last(@foo());
12+
13+
var_dump($var);
14+
15+
echo "Done\n";
16+
?>
17+
--EXPECTF--
18+
Fatal error: Uncaught ArgumentCountError: error_get_last() expects exactly 0 arguments, 1 given in %s:%d
19+
Stack trace:
20+
#0 %s(%d): error_get_last(NULL)
21+
#1 {main}
22+
thrown in %s on line %d
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Listed silencing a internal function supplementary argument throwing an Exception
3+
--FILE--
4+
<?php
5+
6+
function foo() {
7+
throw new Exception();
8+
return 1;
9+
}
10+
11+
$var = error_get_last(@<Exception>foo());
12+
13+
var_dump($var);
14+
15+
echo "Done\n";
16+
?>
17+
--EXPECTF--
18+
Fatal error: Uncaught ArgumentCountError: error_get_last() expects exactly 0 arguments, 1 given in %s:%d
19+
Stack trace:
20+
#0 %s(%d): error_get_last(NULL)
21+
#1 {main}
22+
thrown in %s on line %d
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Silencing a userland function supplementary argument throwing an Exception
3+
--FILE--
4+
<?php
5+
6+
function test1() {
7+
return func_get_args();
8+
}
9+
10+
function foo() {
11+
throw new Exception();
12+
return 1;
13+
}
14+
15+
$var = test1(@foo());
16+
17+
var_dump($var);
18+
19+
echo "Done\n";
20+
?>
21+
--EXPECT--
22+
array(1) {
23+
[0]=>
24+
NULL
25+
}
26+
Done
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Listed silencing a userland function supplementary argument throwing an Exception
3+
--FILE--
4+
<?php
5+
6+
function test1() {
7+
return func_get_args();
8+
}
9+
10+
function foo() {
11+
throw new Exception();
12+
return 1;
13+
}
14+
15+
$var = test1(@<Exception>foo());
16+
17+
var_dump($var);
18+
19+
echo "Done\n";
20+
?>
21+
--EXPECT--
22+
array(1) {
23+
[0]=>
24+
NULL
25+
}
26+
Done

Zend/zend_vm_def.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -7869,8 +7869,7 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY)
78697869
/* Do not cleanup unfinished calls for SILENCE live range as it might still get executed
78707870
* However, this can only happen if the exception is an instance of Exception
78717871
* (Error never gets suppressed) */
7872-
if (!is_in_silence_live_range(EX(func)->op_array, throw_op_num)
7873-
|| !instanceof_function(zend_ce_exception, EG(exception)->ce)) {
7872+
if (!is_in_silence_live_range(EX(func)->op_array, throw_op_num)) {
78747873
cleanup_unfinished_calls(execute_data, throw_op_num);
78757874
}
78767875

Zend/zend_vm_execute.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -3144,8 +3144,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_HANDLE_EXCEPTION_SPEC_HANDLER(
31443144
/* Do not cleanup unfinished calls for SILENCE live range as it might still get executed
31453145
* However, this can only happen if the exception is an instance of Exception
31463146
* (Error never gets suppressed) */
3147-
if (!is_in_silence_live_range(EX(func)->op_array, throw_op_num)
3148-
|| !instanceof_function(zend_ce_exception, EG(exception)->ce)) {
3147+
if (!is_in_silence_live_range(EX(func)->op_array, throw_op_num)) {
31493148
cleanup_unfinished_calls(execute_data, throw_op_num);
31503149
}
31513150

0 commit comments

Comments
 (0)