From dedb2304cda8154cf0cc4e06087557613923bbf8 Mon Sep 17 00:00:00 2001 From: skodak Date: Thu, 17 Aug 2006 22:37:34 +0000 Subject: [PATCH] upgrade logging cleanup, fixes - more improvements ahead --- admin/index.php | 11 ++--------- backup/lib.php | 3 +-- lib/adminlib.php | 1 + lib/blocklib.php | 3 +-- lib/locallib.php | 1 - lib/weblib.php | 15 ++++++++++----- 6 files changed, 15 insertions(+), 19 deletions(-) diff --git a/admin/index.php b/admin/index.php index fb8d422aca..b5f0a4ae90 100644 --- a/admin/index.php +++ b/admin/index.php @@ -80,12 +80,6 @@ $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. @@ -143,7 +137,6 @@ } 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; } @@ -191,7 +184,6 @@ 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 { @@ -204,7 +196,9 @@ 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 { @@ -216,7 +210,6 @@ upgrade_log_start(); $db->debug=true; if (main_upgrade(0)) { - upgrade_log_finish(); print_continue("index.php"); exit; } else { diff --git a/backup/lib.php b/backup/lib.php index ceb5ffc747..65db3d519e 100644 --- a/backup/lib.php +++ b/backup/lib.php @@ -336,7 +336,6 @@ 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 { @@ -362,7 +361,6 @@ 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 { @@ -376,6 +374,7 @@ } 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(); } } diff --git a/lib/adminlib.php b/lib/adminlib.php index 6556bd6341..d44226d1df 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -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 } /** diff --git a/lib/blocklib.php b/lib/blocklib.php index 3bc7927676..f75b726174 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -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(); } } diff --git a/lib/locallib.php b/lib/locallib.php index e8b5515d47..255f5f9ac6 100644 --- a/lib/locallib.php +++ b/lib/locallib.php @@ -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 { diff --git a/lib/weblib.php b/lib/weblib.php index b52f080613..838e063ca8 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -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; } -- 2.39.5