From: Petr Skoda Date: Sun, 1 Nov 2009 10:00:30 +0000 (+0000) Subject: MDL-20699 more abstraction in default exception handler X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=a56c457e52a9ac86eed3cbc9d98245515e4683e3;p=moodle.git MDL-20699 more abstraction in default exception handler --- diff --git a/lib/setuplib.php b/lib/setuplib.php index 0568ced68f..78bdb182df 100644 --- a/lib/setuplib.php +++ b/lib/setuplib.php @@ -168,11 +168,6 @@ class invalid_state_exception extends moodle_exception { function default_exception_handler($ex) { global $DB, $OUTPUT; - if ($DB) { - // If you enable db debugging and exception is thrown, the print footer prints a lot of rubbish - $DB->set_debug(0); - } - // detect active db transactions, rollback and log as error abort_all_db_transactions(); @@ -187,6 +182,10 @@ function default_exception_handler($ex) { echo bootstrap_renderer::early_error($info->message, $info->moreinfourl, $info->link, $info->backtrace, $info->debuginfo); } else { try { + if ($DB) { + // If you enable db debugging and exception is thrown, the print footer prints a lot of rubbish + $DB->set_debug(0); + } echo $OUTPUT->fatal_error($info->message, $info->moreinfourl, $info->link, $info->backtrace, $info->debuginfo); } catch (Exception $out_ex) { // default exception handler MUST not throw any exceptions!! diff --git a/lib/upgradelib.php b/lib/upgradelib.php index 72cedfe577..9be0d1a75e 100644 --- a/lib/upgradelib.php +++ b/lib/upgradelib.php @@ -840,6 +840,9 @@ function external_delete_descriptions($component) { * upgrade logging functions */ function upgrade_handle_exception($ex, $plugin = null) { + // rollback everything, we need to log all upgrade problems + abort_all_db_transactions(); + $info = get_exception_info($ex); // First log upgrade error @@ -1174,7 +1177,6 @@ function install_core($version, $verbose) { print_upgrade_part_end(null, true, $verbose); } catch (exception $ex) { - //TODO: unconditionally rollback DB transaction if active upgrade_handle_exception($ex); } } @@ -1225,7 +1227,6 @@ function upgrade_core($version, $verbose) { print_upgrade_part_end('moodle', false, $verbose); } catch (Exception $ex) { - //TODO: unconditionally rollback DB transaction if active upgrade_handle_exception($ex); } }