]> git.mjollnir.org Git - moodle.git/commitdiff
upgrade logging cleanup, fixes - more improvements ahead
authorskodak <skodak>
Thu, 17 Aug 2006 22:37:34 +0000 (22:37 +0000)
committerskodak <skodak>
Thu, 17 Aug 2006 22:37:34 +0000 (22:37 +0000)
admin/index.php
backup/lib.php
lib/adminlib.php
lib/blocklib.php
lib/locallib.php
lib/weblib.php

index fb8d422acad91fc7cbede749e4f18787913583da..b5f0a4ae906e550fa67f8ab0b60aad281a5b47bf 100644 (file)
         $CFG->version = "";
     }
 
-/// Turn off time limits and try to flush everything all the time, sometimes upgrades can be slow.
-
-    @set_time_limit(0);
-    @ob_implicit_flush(true);
-    @ob_end_flush();
-
 /// Check if the main tables have been installed yet or not.
 
     if (! $tables = $db->Metatables() ) {    // No tables yet at all.
         } else {
             error("Error: Your database ($CFG->dbtype) is not yet fully supported by Moodle.  See the lib/db directory.");
         }
-        upgrade_log_finish();
         print_continue("index.php");
         die;
     }
                     if (set_config("version", $version)) {
                         remove_dir($CFG->dataroot . '/cache', true); // flush cache
                         notify($strdatabasesuccess, "green");
-                        upgrade_log_finish();
                         print_continue("index.php");
                         exit;
                     } else {
                 upgrade_log_finish();
             }
         } else if ($version < $CFG->version) {
+            upgrade_log_start();
             notify("WARNING!!!  The code you are using is OLDER than the version that made these databases!");
+            upgrade_log_finish();
         }
 
     } else {
             upgrade_log_start();
             $db->debug=true;
             if (main_upgrade(0)) {
-                upgrade_log_finish();
                 print_continue("index.php");
                 exit;
             } else {
index ceb5ffc747e1bbed87c02aa7897ae2a4e684670f..65db3d519e28dc45ba78dbc640e00985574ca141 100644 (file)
                 if (set_config("backup_version", $backup_version) and set_config("backup_release", $backup_release)) {
                     notify(get_string("databasesuccess"), "green");
                     notify(get_string("databaseupgradebackups", "", $backup_version), "green");
-                    upgrade_log_finish();
                     print_continue($continueto);
                     exit;
                 } else {
                 if (set_config("backup_version", $backup_version) and set_config("backup_release", $backup_release)) {
                     notify(get_string("databasesuccess"), "green");
                     notify(get_string("databaseupgradebackups", "", $backup_version), "green");
-                    upgrade_log_finish();
                     print_continue($continueto);
                     exit;
                 } else {
         } else if ($backup_version < $CFG->backup_version) {
             upgrade_log_start();
             notify("WARNING!!!  The code you are using is OLDER than the version that made these databases!");
+            upgrade_log_finish();
         }
 
     }
index 6556bd63418453864aaacf420491b3432446bae9..d44226d1dfb8013b2d3d238baf5dd2ba84f0c728 100644 (file)
@@ -441,6 +441,7 @@ function upgrade_log_start() {
     session_write_close();               // from now on user can reload page - will be displayed warning
     make_upload_directory('upgradelogs');
     ob_start('upgrade_log_callback', 2); // function for logging to disk; flush each line of text ASAP
+    register_shutdown_function('upgrade_log_finish'); // in case somebody forgets to stop logging
 }
 
 /**
index 3bc7927676e56ed8f5ca6aec1bdfd35469606688..f75b72617472c69c1f7fa2179a329fc66dd70a36 100644 (file)
@@ -919,7 +919,6 @@ function upgrade_blocks_db($continueto) {
             if (set_config('blocks_version', $blocks_version)) {
                 notify(get_string('databasesuccess'), 'notifysuccess');
                 notify(get_string('databaseupgradeblocks', '', $blocks_version), 'notifysuccess');
-                upgrade_log_finish();
                 print_continue($continueto);
                 exit;
             } else {
@@ -945,7 +944,6 @@ function upgrade_blocks_db($continueto) {
             if (set_config('blocks_version', $blocks_version)) {
                 notify(get_string('databasesuccess'), 'notifysuccess');
                 notify(get_string('databaseupgradeblocks', '', $blocks_version), 'notifysuccess');
-                upgrade_log_finish();
                 print_continue($continueto);
                 exit;
             } else {
@@ -959,6 +957,7 @@ function upgrade_blocks_db($continueto) {
     } else if ($blocks_version < $CFG->blocks_version) {
         upgrade_log_start();
         notify('WARNING!!!  The Blocks version you are using is OLDER than the version that made these databases!');
+        upgrade_log_finish();
     }
 
 }
index e8b5515d47108205f172316117e67b4722db8054..255f5f9ac67ebc7637da3d488cbf96de1b31a56a 100644 (file)
@@ -102,7 +102,6 @@ function upgrade_local_db($continueto) {
             if (set_config('local_version', $local_version)) {
                 notify(get_string('databasesuccess'), 'notifysuccess');
                 notify(get_string('databaseupgradelocal', '', $local_version));
-                upgrade_log_finish();
                 print_continue($continueto);
                 exit;
             } else {
index b52f080613915f42be7a95f35f5c6bfc05c0ff3a..838e063ca873d577cbc70aa56fbb6d20058cd0c7 100644 (file)
@@ -2612,6 +2612,11 @@ function print_continue($link, $return=false) {
 
     global $CFG;
 
+    // in case we are logging upgrade in admin/index.php stop it
+    if (function_exists('upgrade_log_finish')) {
+        upgrade_log_finish();
+    }
+
     $output = '';
 
     if (!$link) {
@@ -4240,6 +4245,11 @@ function error ($message, $link='') {
 
     print_simple_box($message, '', '', '', '', 'errorbox');
 
+    // in case we are logging upgrade in admin/index.php stop it
+    if (function_exists('upgrade_log_finish')) {
+        upgrade_log_finish();
+    }
+
     if (!$link) {
         if ( !empty($SESSION->fromurl) ) {
             $link = $SESSION->fromurl;
@@ -4254,11 +4264,6 @@ function error ($message, $link='') {
         echo ' ';
     }
 
-    // clean upgrade indicator if needed; buffer and log file will be closed automatically
-    if (!empty($_SESSION['upgraderunning'])) {
-        $_SESSION['upgraderunning'] = 0;
-    }
-
     die;
 }