MDL-52284 core: compatibility with Exception/Throwable changes in PHP7

This commit is contained in:
Tony Levi 2015-08-03 16:16:03 +09:30 committed by Marina Glancy
parent 0dfcc2541a
commit d74b7e424f
7 changed files with 43 additions and 8 deletions

View file

@ -378,7 +378,13 @@ function default_exception_handler($ex) {
$DB->set_debug(0);
}
echo $OUTPUT->fatal_error($info->message, $info->moreinfourl, $info->link, $info->backtrace, $info->debuginfo);
} catch (Exception $out_ex) {
} catch (Exception $e) {
$out_ex = $e;
} catch (Throwable $e) {
$out_ex = $e; // PHP7.
}
if (isset($out_ex)) {
// default exception handler MUST not throw any exceptions!!
// the problem here is we do not know if page already started or not, we only know that somebody messed up in outputlib or theme
// so we just print at least something instead of "Exception thrown without a stack frame in Unknown on line 0":-(