From 7544d13c2840ae72e98c4be6461977f47297a38d Mon Sep 17 00:00:00 2001 From: tjhunt Date: Tue, 30 Jun 2009 05:34:50 +0000 Subject: [PATCH] MDL-19077 - re-fix the problem of exceptions being thrown in $OUTPUT->header Also, fix lines theme. --- lib/setuplib.php | 20 ++++++++++++-------- theme/lines/meta.php | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/setuplib.php b/lib/setuplib.php index bfaa223134..240e7df1b3 100644 --- a/lib/setuplib.php +++ b/lib/setuplib.php @@ -155,13 +155,6 @@ function default_exception_handler($ex, $isupgrade = false, $plugin = null) { $place = array('file'=>$ex->getFile(), 'line'=>$ex->getLine(), 'exception'=>get_class($ex)); array_unshift($backtrace, $place); - foreach ($backtrace as $stackframe) { - if (isset($stackframe['function']) && $stackframe['function'] == 'default_exception_handler') { - $earlyerror = true; - break; - } - } - if ($ex instanceof moodle_exception) { $errorcode = $ex->errorcode; $module = $ex->module; @@ -186,6 +179,18 @@ function default_exception_handler($ex, $isupgrade = false, $plugin = null) { $CFG->debug = DEBUG_DEVELOPER; } + // If another exception is thrown when we are already handling one, or during $OUTPUT->header, + // and if we did not take special measures, we would just get a very cryptic message + // "Exception thrown without a stack frame in Unknown on line 0", rather than the true error. + // Therefore, we do take special measures. + foreach ($backtrace as $stackframe) { + if (isset($stackframe['function']) && isset($stackframe['type']) && + $stackframe['type'] == '->' && $stackframe['function'] == 'header') { + echo bootstrap_renderer::early_error($message, $moreinfourl, $link, debug_backtrace()); + exit(1); // General error code + } + } + echo $OUTPUT->fatal_error($message, $moreinfourl, $link, debug_backtrace()); exit(1); // General error code } @@ -800,7 +805,6 @@ class bootstrap_renderer { $strerror = 'Error'; } - $output = ' diff --git a/theme/lines/meta.php b/theme/lines/meta.php index 762d879f1d..d6c65796b9 100755 --- a/theme/lines/meta.php +++ b/theme/lines/meta.php @@ -1,6 +1,6 @@ requires->yui_lib('animation')->in_head(); ?> +echo $PAGE->requires->yui_lib('animation')->asap(); ?>