]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-20699 more abstraction in default exception handler
authorPetr Skoda <skodak@moodle.org>
Sun, 1 Nov 2009 10:00:30 +0000 (10:00 +0000)
committerPetr Skoda <skodak@moodle.org>
Sun, 1 Nov 2009 10:00:30 +0000 (10:00 +0000)
lib/setuplib.php
lib/upgradelib.php

index 0568ced68f4a8cbc99ea1c3bb2c9e24d498e2540..78bdb182df1cfb416dc24a704204081c69d73c69 100644 (file)
@@ -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!!
index 72cedfe577243bbc7d4a403bf4cf118e43729184..9be0d1a75ec0ed29d262003a61f7828f197ceaa0 100644 (file)
@@ -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);
     }
 }