Bug #5352 - upgrade might be interrupted by user - upgrades are now logged into moddata/upgradelogs/, user abor is ignored and concurrent running of upgrades is prevented from one browser

This commit is contained in:
skodak 2006-08-01 07:46:19 +00:00
parent 0c23b59c9b
commit 583fad994c
7 changed files with 173 additions and 10 deletions

View file

@ -29,6 +29,9 @@
$agreelicence = optional_param('agreelicence',0, PARAM_BOOL); $agreelicence = optional_param('agreelicence',0, PARAM_BOOL);
/// check upgrade status first
upgrade_check_running("Upgrade already running, please wait!", 10);
/// Check some PHP server settings /// Check some PHP server settings
$documentationlink = "please read the <a href=\"../doc/?frame=install.html&amp;sub=webserver\">install documentation</a>"; $documentationlink = "please read the <a href=\"../doc/?frame=install.html&amp;sub=webserver\">install documentation</a>";
@ -115,6 +118,7 @@
print_header($strdatabasesetup, $strdatabasesetup, $strdatabasesetup, print_header($strdatabasesetup, $strdatabasesetup, $strdatabasesetup,
"", $linktoscrolltoerrors, false, "&nbsp;", "&nbsp;"); "", $linktoscrolltoerrors, false, "&nbsp;", "&nbsp;");
if (file_exists("$CFG->libdir/db/$CFG->dbtype.sql")) { if (file_exists("$CFG->libdir/db/$CFG->dbtype.sql")) {
upgrade_log_start();
$db->debug = true; $db->debug = true;
if (modify_database("$CFG->libdir/db/$CFG->dbtype.sql")) { if (modify_database("$CFG->libdir/db/$CFG->dbtype.sql")) {
$db->debug = false; $db->debug = false;
@ -126,6 +130,7 @@
} else { } else {
error("Error: Your database ($CFG->dbtype) is not yet fully supported by Moodle. See the lib/db directory."); 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"); print_continue("index.php");
die; die;
} }
@ -156,6 +161,7 @@
$strdatabasesuccess = get_string("databasesuccess"); $strdatabasesuccess = get_string("databasesuccess");
print_header($strdatabasechecking, $stradministration, $strdatabasechecking, print_header($strdatabasechecking, $stradministration, $strdatabasechecking,
"", $linktoscrolltoerrors, false, "&nbsp;", "&nbsp;"); "", $linktoscrolltoerrors, false, "&nbsp;", "&nbsp;");
upgrade_log_start();
print_heading($strdatabasechecking); print_heading($strdatabasechecking);
$db->debug=true; $db->debug=true;
if (main_upgrade($CFG->version)) { if (main_upgrade($CFG->version)) {
@ -163,6 +169,7 @@
if (set_config("version", $version)) { if (set_config("version", $version)) {
remove_dir($CFG->dataroot . '/cache', true); // flush cache remove_dir($CFG->dataroot . '/cache', true); // flush cache
notify($strdatabasesuccess, "green"); notify($strdatabasesuccess, "green");
upgrade_log_finish();
print_continue("index.php"); print_continue("index.php");
exit; exit;
} else { } else {
@ -172,6 +179,7 @@
$db->debug=false; $db->debug=false;
notify("Upgrade failed! See /version.php"); notify("Upgrade failed! See /version.php");
} }
upgrade_log_finish();
} }
} else if ($version < $CFG->version) { } else if ($version < $CFG->version) {
notify("WARNING!!! The code you are using is OLDER than the version that made these databases!"); notify("WARNING!!! The code you are using is OLDER than the version that made these databases!");
@ -183,9 +191,12 @@
"", "", false, "&nbsp;", "&nbsp;"); "", "", false, "&nbsp;", "&nbsp;");
if (!set_config("version", $version)) { if (!set_config("version", $version)) {
upgrade_log_start();
$db->debug=true; $db->debug=true;
if (main_upgrade(0)) { if (main_upgrade(0)) {
upgrade_log_finish();
print_continue("index.php"); print_continue("index.php");
exit;
} else { } else {
error("A problem occurred inserting current version into databases"); error("A problem occurred inserting current version into databases");
} }
@ -200,7 +211,9 @@
print_header($strcurrentrelease, $strcurrentrelease, $strcurrentrelease, "", "", false, "&nbsp;", "&nbsp;"); print_header($strcurrentrelease, $strcurrentrelease, $strcurrentrelease, "", "", false, "&nbsp;", "&nbsp;");
print_heading("Moodle $release"); print_heading("Moodle $release");
if (!set_config("release", $release)) { if (!set_config("release", $release)) {
upgrade_log_start();
notify("ERROR: Could not update release version in database!!"); notify("ERROR: Could not update release version in database!!");
upgrade_log_finish();
} }
notice(get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/en/Release_Notes'), 'index.php'); notice(get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/en/Release_Notes'), 'index.php');
exit; exit;
@ -252,6 +265,8 @@
require_once("$CFG->dirroot/lib/locallib.php"); require_once("$CFG->dirroot/lib/locallib.php");
upgrade_local_db("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards upgrade_local_db("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
/// just make sure upgrade logging is properly terminated
upgrade_log_finish();
/// Set up the overall site name etc. /// Set up the overall site name etc.
if (! $site = get_site()) { if (! $site = get_site()) {

View file

@ -327,12 +327,14 @@
'<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>', '<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>',
false, "&nbsp;", "&nbsp;"); false, "&nbsp;", "&nbsp;");
upgrade_log_start();
$db->debug=true; $db->debug=true;
if (modify_database("$CFG->dirroot/backup/db/$CFG->dbtype.sql")) { if (modify_database("$CFG->dirroot/backup/db/$CFG->dbtype.sql")) {
$db->debug = false; $db->debug = false;
if (set_config("backup_version", $backup_version) and set_config("backup_release", $backup_release)) { if (set_config("backup_version", $backup_version) and set_config("backup_release", $backup_release)) {
notify(get_string("databasesuccess"), "green"); notify(get_string("databasesuccess"), "green");
notify(get_string("databaseupgradebackups", "", $backup_version)); notify(get_string("databaseupgradebackups", "", $backup_version));
upgrade_log_finish();
print_continue($continueto); print_continue($continueto);
exit; exit;
} else { } else {
@ -349,6 +351,7 @@
print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, '', print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, '',
'<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>'); '<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>');
upgrade_log_start();
require_once ("$CFG->dirroot/backup/db/$CFG->dbtype.php"); require_once ("$CFG->dirroot/backup/db/$CFG->dbtype.php");
$db->debug=true; $db->debug=true;
@ -357,6 +360,7 @@
if (set_config("backup_version", $backup_version) and set_config("backup_release", $backup_release)) { if (set_config("backup_version", $backup_version) and set_config("backup_release", $backup_release)) {
notify(get_string("databasesuccess"), "green"); notify(get_string("databasesuccess"), "green");
notify(get_string("databaseupgradebackups", "", $backup_version)); notify(get_string("databaseupgradebackups", "", $backup_version));
upgrade_log_finish();
print_continue($continueto); print_continue($continueto);
exit; exit;
} else { } else {
@ -368,8 +372,10 @@
} }
} else if ($backup_version < $CFG->backup_version) { } 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!"); notify("WARNING!!! The code you are using is OLDER than the version that made these databases!");
} }
} }

View file

@ -26,6 +26,9 @@ function upgrade_plugins($type, $dir, $return) {
error('No '.$type.' plugins installed!'); error('No '.$type.' plugins installed!');
} }
$updated_plugins = false;
$strpluginsetup = get_string('pluginsetup');
foreach ($plugs as $plug) { foreach ($plugs as $plug) {
$fullplug = $CFG->dirroot .'/'.$dir.'/'. $plug; $fullplug = $CFG->dirroot .'/'.$dir.'/'. $plug;
@ -54,7 +57,14 @@ function upgrade_plugins($type, $dir, $return) {
$info->pluginversion = $plugin->version; $info->pluginversion = $plugin->version;
$info->currentmoodle = $CFG->version; $info->currentmoodle = $CFG->version;
$info->requiremoodle = $plugin->requires; $info->requiremoodle = $plugin->requires;
if (!$updated_plugins) {
print_header($strpluginsetup, $strpluginsetup, $strpluginsetup, '',
'<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>',
false, '&nbsp;', '&nbsp;');
}
upgrade_log_start();
notify(get_string('pluginrequirementsnotmet', 'error', $info)); notify(get_string('pluginrequirementsnotmet', 'error', $info));
$updated_plugins = true;
unset($info); unset($info);
continue; continue;
} }
@ -71,14 +81,13 @@ function upgrade_plugins($type, $dir, $return) {
if ($CFG->$pluginversion == $plugin->version) { if ($CFG->$pluginversion == $plugin->version) {
// do nothing // do nothing
} else if ($CFG->$pluginversion < $plugin->version) { } else if ($CFG->$pluginversion < $plugin->version) {
if (empty($updated_plugins)) { if (!$updated_plugins) {
$strpluginsetup = get_string('pluginsetup');
print_header($strpluginsetup, $strpluginsetup, $strpluginsetup, '', print_header($strpluginsetup, $strpluginsetup, $strpluginsetup, '',
'<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>', '<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>',
false, '&nbsp;', '&nbsp;'); false, '&nbsp;', '&nbsp;');
} }
upgrade_log_start();
print_heading($plugin->name .' plugin needs upgrading'); print_heading($plugin->name .' plugin needs upgrading');
if ($CFG->$pluginversion == 0) { // It's a new install of this plugin if ($CFG->$pluginversion == 0) { // It's a new install of this plugin
if (file_exists($fullplug .'/db/'. $CFG->dbtype .'.sql')) { if (file_exists($fullplug .'/db/'. $CFG->dbtype .'.sql')) {
$db->debug = true; $db->debug = true;
@ -112,13 +121,15 @@ function upgrade_plugins($type, $dir, $return) {
} }
echo '<hr />'; echo '<hr />';
$updated_plugins = true; $updated_plugins = true;
} else { } else {
upgrade_log_start();
error('Version mismatch: '. $plugin->name .' can\'t downgrade '. $CFG->$pluginversion .' -> '. $plugin->version .' !'); error('Version mismatch: '. $plugin->name .' can\'t downgrade '. $CFG->$pluginversion .' -> '. $plugin->version .' !');
} }
} }
if (!empty($updated_plugins)) { upgrade_log_finish();
if ($updated_plugins) {
print_continue($return); print_continue($return);
die; die;
} }
@ -140,6 +151,9 @@ function upgrade_activity_modules($return) {
error('No modules installed!'); error('No modules installed!');
} }
$updated_modules = false;
$strmodulesetup = get_string('modulesetup');
foreach ($mods as $mod) { foreach ($mods as $mod) {
if ($mod == 'NEWMODULE') { // Someone has unzipped the template, ignore it if ($mod == 'NEWMODULE') { // Someone has unzipped the template, ignore it
@ -174,7 +188,14 @@ function upgrade_activity_modules($return) {
$info->moduleversion = $module->version; $info->moduleversion = $module->version;
$info->currentmoodle = $CFG->version; $info->currentmoodle = $CFG->version;
$info->requiremoodle = $module->requires; $info->requiremoodle = $module->requires;
if (!$updated_modules) {
print_header($strmodulesetup, $strmodulesetup, $strmodulesetup, '',
'<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>',
false, '&nbsp;', '&nbsp;');
}
upgrade_log_start();
notify(get_string('modulerequirementsnotmet', 'error', $info)); notify(get_string('modulerequirementsnotmet', 'error', $info));
$updated_modules = true;
unset($info); unset($info);
continue; continue;
} }
@ -186,12 +207,12 @@ function upgrade_activity_modules($return) {
if ($currmodule->version == $module->version) { if ($currmodule->version == $module->version) {
// do nothing // do nothing
} else if ($currmodule->version < $module->version) { } else if ($currmodule->version < $module->version) {
if (empty($updated_modules)) { if (!$updated_modules) {
$strmodulesetup = get_string('modulesetup');
print_header($strmodulesetup, $strmodulesetup, $strmodulesetup, '', print_header($strmodulesetup, $strmodulesetup, $strmodulesetup, '',
'<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>', '<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>',
false, '&nbsp;', '&nbsp;'); false, '&nbsp;', '&nbsp;');
} }
upgrade_log_start();
print_heading($module->name .' module needs upgrading'); print_heading($module->name .' module needs upgrading');
$upgrade_function = $module->name.'_upgrade'; $upgrade_function = $module->name.'_upgrade';
if (function_exists($upgrade_function)) { if (function_exists($upgrade_function)) {
@ -213,16 +234,17 @@ function upgrade_activity_modules($return) {
} }
$updated_modules = true; $updated_modules = true;
} else { } else {
upgrade_log_start();
error('Version mismatch: '. $module->name .' can\'t downgrade '. $currmodule->version .' -> '. $module->version .' !'); error('Version mismatch: '. $module->name .' can\'t downgrade '. $currmodule->version .' -> '. $module->version .' !');
} }
} else { // module not installed yet, so install it } else { // module not installed yet, so install it
if (empty($updated_modules)) { if (!$updated_modules) {
$strmodulesetup = get_string('modulesetup');
print_header($strmodulesetup, $strmodulesetup, $strmodulesetup, '', print_header($strmodulesetup, $strmodulesetup, $strmodulesetup, '',
'<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>', '<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>',
false, '&nbsp;', '&nbsp;'); false, '&nbsp;', '&nbsp;');
} }
upgrade_log_start();
print_heading($module->name); print_heading($module->name);
$updated_modules = true; $updated_modules = true;
$db->debug = true; $db->debug = true;
@ -266,7 +288,9 @@ function upgrade_activity_modules($return) {
} }
} }
if (!empty($updated_modules)) { upgrade_log_finish(); // finish logging if started
if ($updated_modules) {
print_continue($return); print_continue($return);
print_footer(); print_footer();
die; die;
@ -355,4 +379,95 @@ function print_progress($done, $total, $updatetime=5, $sleeptime=1, $donetext=''
sleep($sleeptime); sleep($sleeptime);
} }
} }
////////////////////////////////////////////////
/// upgrade logging functions
////////////////////////////////////////////////
$upgradeloghandle = false;
global $upgradeloghandle; // needed for access from callback funtion
/**
* Check if upgrade is already running.
*
* If anything goes wrong due to missing call to upgrade_log_finish()
* just restart the browser.
*
* @param string warning message indicating upgrade is already running
* @param int page reload timeout
*/
function upgrade_check_running($message, $timeout) {
if (!empty($_SESSION['upgraderunning'])) {
print_header();
redirect(me(), $message, $timeout);
}
}
/**
* Start logging of output into file (if not disabled) and
* prevent aborting and concurrent execution of upgrade script.
*
* Please note that you can not write into session variables after calling this function!
*
* This function may be called repeatedly.
*/
function upgrade_log_start() {
global $upgradeloghandle;
if (!empty($_SESSION['upgraderunning'])) {
return; // logging already started
}
@ignore_user_abort(true); // ignore if user stops or otherwise aborts page loading
$_SESSION['upgraderunning'] = 1; // set upgrade indicator
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
}
/**
* Terminate logging of output, flush all data, allow script aborting
* and reopen session for writing. Function error() does terminate the logging too.
*
* Please make sure that each upgrade_log_start() is properly terminated by
* this function or error().
*
* This function may be called repeatedly.
*/
function upgrade_log_finish() {
global $upgradeloghandle;
if (empty($_SESSION['upgraderunning'])) {
return; // logging already terminated
}
@ob_end_flush();
@fclose($upgradeloghandle);
@session_start(); // ignore header errors, we only need to reopen session
$_SESSION['upgraderunning'] = 0; // clear upgrade indicator
if (connection_aborted()) {
die;
}
@ignore_user_abort(false);
}
/**
* Callback function for logging into files. Not more than one file is created per minute,
* upgrade session (terminated by upgrade_log_finish()) is always stored in one file.
*
* This function must not output any characters or throw warnigns and errors!
*/
function upgrade_log_callback($string) {
global $CFG, $upgradeloghandle;
if (empty($CFG->disableupgradelogging) and ($string != '') and ($upgradeloghandle !== 'error')) {
if ($upgradeloghandle or ($upgradeloghandle = @fopen($CFG->dataroot.'/upgradelogs/upg_'.date('Ymd-Hi').'.html', 'a'))) {
@fwrite($upgradeloghandle, $string);
} else {
$upgradeloghandle = 'error';
}
}
return $string;
}
?> ?>

View file

@ -912,12 +912,14 @@ function upgrade_blocks_db($continueto) {
'<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>', '<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>',
false, '&nbsp;', '&nbsp;'); false, '&nbsp;', '&nbsp;');
upgrade_log_start();
$db->debug=true; $db->debug=true;
if (modify_database($CFG->dirroot .'/blocks/db/'. $CFG->dbtype .'.sql')) { if (modify_database($CFG->dirroot .'/blocks/db/'. $CFG->dbtype .'.sql')) {
$db->debug = false; $db->debug = false;
if (set_config('blocks_version', $blocks_version)) { if (set_config('blocks_version', $blocks_version)) {
notify(get_string('databasesuccess'), 'notifysuccess'); notify(get_string('databasesuccess'), 'notifysuccess');
notify(get_string('databaseupgradeblocks', '', $blocks_version)); notify(get_string('databaseupgradeblocks', '', $blocks_version));
upgrade_log_finish();
print_continue($continueto); print_continue($continueto);
exit; exit;
} else { } else {
@ -933,6 +935,8 @@ function upgrade_blocks_db($continueto) {
$strdatabaseupgrades = get_string('databaseupgrades'); $strdatabaseupgrades = get_string('databaseupgrades');
print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, '', print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, '',
'<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>'); '<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>');
upgrade_log_start();
require_once ($CFG->dirroot .'/blocks/db/'. $CFG->dbtype .'.php'); require_once ($CFG->dirroot .'/blocks/db/'. $CFG->dbtype .'.php');
$db->debug=true; $db->debug=true;
@ -941,6 +945,7 @@ function upgrade_blocks_db($continueto) {
if (set_config('blocks_version', $blocks_version)) { if (set_config('blocks_version', $blocks_version)) {
notify(get_string('databasesuccess'), 'notifysuccess'); notify(get_string('databasesuccess'), 'notifysuccess');
notify(get_string('databaseupgradeblocks', '', $blocks_version)); notify(get_string('databaseupgradeblocks', '', $blocks_version));
upgrade_log_finish();
print_continue($continueto); print_continue($continueto);
exit; exit;
} else { } else {
@ -952,8 +957,10 @@ function upgrade_blocks_db($continueto) {
} }
} else if ($blocks_version < $CFG->blocks_version) { } 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!'); notify('WARNING!!! The Blocks version you are using is OLDER than the version that made these databases!');
} }
} }
//This function finds all available blocks and install them //This function finds all available blocks and install them
@ -1069,6 +1076,7 @@ function upgrade_blocks_plugins($continueto) {
'<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>', '<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>',
false, '&nbsp;', '&nbsp;'); false, '&nbsp;', '&nbsp;');
} }
upgrade_log_start();
print_heading('New version of '.$blocktitle.' ('.$block->name.') exists'); print_heading('New version of '.$blocktitle.' ('.$block->name.') exists');
$upgrade_function = $block->name.'_upgrade'; $upgrade_function = $block->name.'_upgrade';
if (function_exists($upgrade_function)) { if (function_exists($upgrade_function)) {
@ -1098,6 +1106,7 @@ function upgrade_blocks_plugins($continueto) {
} }
$updated_blocks = true; $updated_blocks = true;
} else { } else {
upgrade_log_start();
error('Version mismatch: block '. $block->name .' can\'t downgrade '. $currblock->version .' -> '. $block->version .'!'); error('Version mismatch: block '. $block->name .' can\'t downgrade '. $currblock->version .' -> '. $block->version .'!');
} }
@ -1123,6 +1132,7 @@ function upgrade_blocks_plugins($continueto) {
'<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>', '<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>',
false, '&nbsp;', '&nbsp;'); false, '&nbsp;', '&nbsp;');
} }
upgrade_log_start();
print_heading($block->name); print_heading($block->name);
$updated_blocks = true; $updated_blocks = true;
$db->debug = true; $db->debug = true;
@ -1145,6 +1155,7 @@ function upgrade_blocks_plugins($continueto) {
} }
if(!empty($notices)) { if(!empty($notices)) {
upgrade_log_start();
foreach($notices as $notice) { foreach($notices as $notice) {
notify($notice); notify($notice);
} }
@ -1153,6 +1164,7 @@ function upgrade_blocks_plugins($continueto) {
// Finally, if we are in the first_install of BLOCKS (this means that we are // Finally, if we are in the first_install of BLOCKS (this means that we are
// upgrading from Moodle < 1.3), put blocks in all existing courses. // upgrading from Moodle < 1.3), put blocks in all existing courses.
if ($first_install) { if ($first_install) {
upgrade_log_start();
//Iterate over each course //Iterate over each course
if ($courses = get_records('course')) { if ($courses = get_records('course')) {
foreach ($courses as $course) { foreach ($courses as $course) {
@ -1163,11 +1175,14 @@ function upgrade_blocks_plugins($continueto) {
} }
if (!empty($CFG->siteblocksadded)) { /// This is a once-off hack to make a proper upgrade if (!empty($CFG->siteblocksadded)) { /// This is a once-off hack to make a proper upgrade
upgrade_log_start();
$page = page_create_object(PAGE_COURSE_VIEW, SITEID); $page = page_create_object(PAGE_COURSE_VIEW, SITEID);
blocks_repopulate_page($page); blocks_repopulate_page($page);
delete_records('config', 'name', 'siteblocksadded'); delete_records('config', 'name', 'siteblocksadded');
} }
upgrade_log_finish();
if (!empty($updated_blocks)) { if (!empty($updated_blocks)) {
print_continue($continueto); print_continue($continueto);
die; die;

View file

@ -93,6 +93,7 @@ function upgrade_local_db($continueto) {
print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, '', print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, '',
'<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>'); '<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>');
upgrade_log_start();
require_once ($CFG->dirroot .'/local/db/'. $CFG->dbtype .'.php'); require_once ($CFG->dirroot .'/local/db/'. $CFG->dbtype .'.php');
$db->debug=true; $db->debug=true;
@ -101,6 +102,7 @@ function upgrade_local_db($continueto) {
if (set_config('local_version', $local_version)) { if (set_config('local_version', $local_version)) {
notify(get_string('databasesuccess'), 'notifysuccess'); notify(get_string('databasesuccess'), 'notifysuccess');
notify(get_string('databaseupgradelocal', '', $local_version)); notify(get_string('databaseupgradelocal', '', $local_version));
upgrade_log_finish();
print_continue($continueto); print_continue($continueto);
exit; exit;
} else { } else {
@ -112,8 +114,10 @@ function upgrade_local_db($continueto) {
} }
} else if ($local_version < $CFG->local_version) { } else if ($local_version < $CFG->local_version) {
upgrade_log_start();
notify('WARNING!!! The local version you are using is OLDER than the version that made these databases!'); notify('WARNING!!! The local version you are using is OLDER than the version that made these databases!');
} }
upgrade_log_finish();
} }
/** /**

View file

@ -4089,6 +4089,12 @@ function error ($message, $link='') {
for ($i=0;$i<512;$i++) { // Padding to help IE work with 404 for ($i=0;$i<512;$i++) { // Padding to help IE work with 404
echo ' '; echo ' ';
} }
// clean upgrade indicator if needed; buffer and log file will be closed automatically
if (!empty($_SESSION['upgraderunning'])) {
$_SESSION['upgraderunning'] = 0;
}
die; die;
} }

View file

@ -2263,6 +2263,7 @@ function assignment_upgrade_submodules() {
continue; continue;
} }
upgrade_log_start();
$db->debug=true; $db->debug=true;
if (!modify_database($fullpath .'/db/'.$CFG->dbtype.'.sql')) { if (!modify_database($fullpath .'/db/'.$CFG->dbtype.'.sql')) {
notify("Error installing tables for submodule '$type'!"); notify("Error installing tables for submodule '$type'!");
@ -2289,6 +2290,7 @@ function assignment_upgrade_submodules() {
$upgrade_function = 'assignment_'.$type.'_upgrade'; $upgrade_function = 'assignment_'.$type.'_upgrade';
if (function_exists($upgrade_function)) { if (function_exists($upgrade_function)) {
upgrade_log_start();
$db->debug=true; $db->debug=true;
if ($upgrade_function($CFG->$currentversion)) { if ($upgrade_function($CFG->$currentversion)) {
$db->debug=false; $db->debug=false;