Skip to content

Commit 83fa045

Browse files
committed
Drop check for exception type and add tests
1 parent 94a2904 commit 83fa045

6 files changed

+98
-4
lines changed
Lines changed: 22 additions & 0 deletions
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
Lines changed: 22 additions & 0 deletions
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
Lines changed: 26 additions & 0 deletions
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
Lines changed: 26 additions & 0 deletions
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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7978,8 +7978,7 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY)
79787978
/* Do not cleanup unfinished calls for SILENCE live range as it might still get executed
79797979
* However, this can only happen if the exception is an instance of Exception
79807980
* (Error never gets suppressed) */
7981-
if (!is_in_silence_live_range(EX(func)->op_array, throw_op_num)
7982-
|| !instanceof_function(zend_ce_exception, EG(exception)->ce)) {
7981+
if (!is_in_silence_live_range(EX(func)->op_array, throw_op_num)) {
79837982
cleanup_unfinished_calls(execute_data, throw_op_num);
79847983
}
79857984

Zend/zend_vm_execute.h

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)