Skip to content
Snippets Groups Projects
Commit b2bfd47d authored by Jaime Pérez's avatar Jaime Pérez
Browse files

bugfix: Exception handler compatible with PHP 7.

PHP 7 changed the way it handles internal errors. Now, Exception objects inherit from the Throwable interface, as well as the new Error objects. Internal functions throw Error objects now instead of raising an error, so the exception handler would need to handle them as well. Therefore, the exception handler is no longer guaranteed to receive an Exception object. We need now to discern whether the parameter is an exception (and continue our business as usual), or an Error (in case such thing exists, only PHP 7), and in this last case parse it and let the error handler do its stuff.

This should resolve #330.
parent 1fa16596
No related branches found
No related tags found
No related merge requests found
......@@ -35,15 +35,23 @@ require_once(dirname(dirname(__FILE__)).'/lib/_autoload.php');
SimpleSAML_Error_Assertion::installHandler();
// show error page on unhandled exceptions
function SimpleSAML_exception_handler(Exception $exception)
function SimpleSAML_exception_handler($exception)
{
SimpleSAML\Module::callHooks('exception_handler', $exception);
if ($exception instanceof SimpleSAML_Error_Error) {
$exception->show();
} else {
} elseif ($exception instanceof Exception) {
$e = new SimpleSAML_Error_Error('UNHANDLEDEXCEPTION', $exception);
$e->show();
} else {
if (class_exists('Error') && $exception instanceof Error) {
$errno = $exception->getCode();
$errstr = $exception->getMessage();
$errfile = $exception->getFile();
$errline = $exception->getLine();
SimpleSAML_error_handler($errno, $errstr, $errfile, $errline);
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment