File tree Expand file tree Collapse file tree 3 files changed +32
-6
lines changed Expand file tree Collapse file tree 3 files changed +32
-6
lines changed Original file line number Diff line number Diff line change @@ -7,17 +7,19 @@ class test1 {
7
7
register_shutdown_function (array ($ this , 'shutdown ' ));
8
8
}
9
9
public function shutdown () {
10
- exit (__METHOD__ );
10
+ exit (static ::class . ' :: ' . __FUNCTION__ . "\n" );
11
11
}
12
12
}
13
13
14
14
class test2 extends test1 {
15
15
public function __destruct () {
16
- exit ( __METHOD__ );
16
+ exit ( static ::class . ' :: ' . __FUNCTION__ . "\n" );
17
17
}
18
18
}
19
19
new test1 ;
20
20
new test2 ;
21
21
?>
22
22
--EXPECT--
23
- test1::shutdowntest2::__destruct
23
+ test1::shutdown
24
+ test2::shutdown
25
+ test2::__destruct
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Gh-18619: exit() from error handler should not trigger bailout
3
+ --FILE--
4
+ <?php
5
+
6
+ function foo ($ e ) {
7
+ exit ;
8
+ }
9
+
10
+ set_exception_handler ('foo ' );
11
+
12
+ register_shutdown_function (function () {
13
+ var_dump (set_exception_handler (null ));
14
+ });
15
+
16
+ throw new Error ();
17
+
18
+ ?>
19
+ --EXPECT--
20
+ string(3) "foo"
Original file line number Diff line number Diff line change @@ -210,9 +210,13 @@ ZEND_API ZEND_COLD void zend_throw_exception_internal(zend_object *exception) /*
210
210
return ;
211
211
}
212
212
if (EG (exception )) {
213
- if (Z_TYPE (EG (user_exception_handler )) != IS_UNDEF
214
- && !zend_is_unwind_exit (EG (exception ))
215
- && !zend_is_graceful_exit (EG (exception ))) {
213
+ if (zend_is_unwind_exit (EG (exception ))
214
+ || zend_is_graceful_exit (EG (exception ))) {
215
+ /* Stack is fully unwound, clear the unwind exit. */
216
+ zend_exception_error (EG (exception ), E_ERROR );
217
+ return ;
218
+ }
219
+ if (Z_TYPE (EG (user_exception_handler )) != IS_UNDEF ) {
216
220
zend_user_exception_handler ();
217
221
if (EG (exception )) {
218
222
zend_exception_error (EG (exception ), E_ERROR );
You can’t perform that action at this time.
0 commit comments