mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
3301d9602a
Symfony relies on finding the exception handler in the handler stack. There's currently no clean API to find it, so they pop all the handlers, and push them again once the stack is empty. This PR attempts to minimize the BC break by pushing the current handler onto the stack and clearing the current handler, and restoring it once it has finished. This is essentially equivalent to set_exception_handler(null) and restore_exception_handler(). restore_exception_handler() however is only called if the exception handler is still unset. If the handler has pushed a new handler in the meantime, we assume it knows what it's doing. Fixes GH-13446 Closes GH-13686
17 lines
309 B
PHP
17 lines
309 B
PHP
--TEST--
|
|
GH-13446: Exception handler attempting to free itself
|
|
--FILE--
|
|
<?php
|
|
$x = new \stdClass();
|
|
$handler = function ($ex) use (&$handler, $x) {
|
|
$handler = null;
|
|
var_dump($x);
|
|
};
|
|
unset($x);
|
|
set_exception_handler($handler);
|
|
throw new Exception('Unhandled');
|
|
?>
|
|
--EXPECT--
|
|
object(stdClass)#1 (0) {
|
|
}
|