You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm running into an infinite recursion when throwing an exception somehwere.
The PhpErrorController:on_exception exception handler is correctly called and logs the exception, but it then calls restore_exception_handler and re-throws the Exception which triggers the same function again.
According to a comment in the PHP docs:
Note that this does not work within an exception handler.
Therefore it runs the same method over and over again.
Reproduction instructions
Bootstrap the default configuration
Throw an exception somewhere in the code (e.g. on init)
See how the request times out because of maximul call stack size and the log is full of the same error message
alternative to 3: step-debug with xdebug and see the on_exception method get called over and over again
Expected behavior
In my case I just wanted to test the logging by manually throwing an exception. But when a real one throws, it loggs a huge amount of the same message and runs into fatal error with "Maximum call stack size".
I found out that you can use set_exception_handler(null); to reset it to the PHP defaults exception handler. Then the on_fatal will be called, because the exception is unhandled.
Another possibility would be to save the return-value of set_exception_handler (= the previous one) in Controller::log_php_errors and restore to it later.
Description of the bug
I'm running into an infinite recursion when throwing an exception somehwere.
The
PhpErrorController:on_exception
exception handler is correctly called and logs the exception, but it then callsrestore_exception_handler
and re-throws the Exception which triggers the same function again.According to a comment in the PHP docs:
Therefore it runs the same method over and over again.
Reproduction instructions
init
)on_exception
method get called over and over againExpected behavior
In my case I just wanted to test the logging by manually throwing an exception. But when a real one throws, it loggs a huge amount of the same message and runs into fatal error with "Maximum call stack size".
I found out that you can use
set_exception_handler(null);
to reset it to the PHP defaults exception handler. Then theon_fatal
will be called, because the exception is unhandled.Another possibility would be to save the return-value of
set_exception_handler
(= the previous one) inController::log_php_errors
and restore to it later.Environment info
Relevant log output
Additional context
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: