Skip to content

Commit

Permalink
All upgrades now print a warning, allowing people to avoid accidental…
Browse files Browse the repository at this point in the history
… upgrading
  • Loading branch information
moodler committed Sep 4, 2004
1 parent 74aa723 commit 6981792
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 39 deletions.
91 changes: 53 additions & 38 deletions admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,65 +123,58 @@
}


/// Insert default values for any important configuration variables

include_once("$CFG->dirroot/lib/defaults.php");

foreach ($defaults as $name => $value) {
if (!isset($CFG->$name)) {
$CFG->$name = $value;
set_config($name, $value);
$configchange = true;
}
}

/// If any new configurations were found then send to the config page to check

if (!empty($configchange)) {
redirect("config.php");
}


/// Check version of Moodle code on disk compared with database
/// and upgrade if possible.

include_once("$CFG->dirroot/version.php"); # defines $version
include_once("$CFG->dirroot/lib/db/$CFG->dbtype.php"); # defines upgrades

$stradministration = get_string("administration");

if ($CFG->version) {
if ($version > $CFG->version) { // upgrade
$a->oldversion = $CFG->version;
$a->newversion = $version;

$a->oldversion = "$CFG->release ($CFG->version)";
$a->newversion = "$release ($version)";
$strdatabasechecking = get_string("databasechecking", "", $a);
$strdatabasesuccess = get_string("databasesuccess");
print_header($strdatabasechecking, $strdatabasechecking, $strdatabasechecking,
"", "", false, " ", " ");
print_heading($strdatabasechecking);
$db->debug=true;
if (main_upgrade($CFG->version)) {
$db->debug=false;
if (set_config("version", $version)) {
notify($strdatabasesuccess, "green");
print_continue("index.php");
die;

if (empty($_GET['confirmupgrade'])) {
print_header($strdatabasechecking, $stradministration, $strdatabasechecking,
"", "", false, " ", " ");
notice_yesno(get_string('upgradesure', 'admin', $a->newversion), 'index.php?confirmupgrade=yes', 'index.php');
exit;

} else {
$strdatabasesuccess = get_string("databasesuccess");
print_header($strdatabasechecking, $stradministration, $strdatabasechecking,
"", "", false, " ", " ");
print_heading($strdatabasechecking);
$db->debug=true;
if (main_upgrade($CFG->version)) {
$db->debug=false;
if (set_config("version", $version)) {
notify($strdatabasesuccess, "green");
print_continue("index.php");
exit;
} else {
notify("Upgrade failed! (Could not update version in config table)");
}
} else {
notify("Upgrade failed! (Could not update version in config table)");
$db->debug=false;
notify("Upgrade failed! See /version.php");
}
} else {
$db->debug=false;
notify("Upgrade failed! See /version.php");
}
} else if ($version < $CFG->version) {
notify("WARNING!!! The code you are using is OLDER than the version that made these databases!");
}

} else {
$strcurrentversion = get_string("currentversion");
print_header($strcurrentversion, $strcurrentversion, $strcurrentversion,
print_header($strcurrentversion, $stradministration, $strcurrentversion,
"", "", false, "&nbsp;", "&nbsp;");

if (set_config("version", $version)) {
print_heading("You are currently using Moodle version $version (Release $release)");
print_heading("Moodle $release ($version)");
print_continue("index.php");
die;
} else {
Expand All @@ -195,6 +188,7 @@
}
}


/// Updated human-readable release version if necessary

if ($release <> $CFG->release) { // Update the release version
Expand All @@ -213,6 +207,27 @@
}



/// Insert default values for any important configuration variables

include_once("$CFG->dirroot/lib/defaults.php");

foreach ($defaults as $name => $value) {
if (!isset($CFG->$name)) {
$CFG->$name = $value;
set_config($name, $value);
$configchange = true;
}
}

/// If any new configurations were found then send to the config page to check

if (!empty($configchange)) {
redirect("config.php");
}



/// Upgrade backup/restore system if necessary
require_once("$CFG->dirroot/backup/lib.php");
upgrade_backup_db("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
Expand Down
4 changes: 4 additions & 0 deletions lang/en/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
$string['upgradelogs'] = 'For full functionality, your old logs need to be upgraded. <a href=\"$a\">More information</a>';
$string['upgradelogsinfo'] = 'Some changes have recently been made in the way logs are stored. To be able to view all of your old logs on a per-activity basis, your old logs need to be upgraded. Depending on your site this can take a long time (eg several hours) and can be quite taxing on the database for large sites. Once you start this process you should let it finish (by keeping the browser window open). Don\'t worry - your site will work fine for other people while the logs are being upgraded.<br /><br />Do you want to upgrade your logs now?';

$string['upgradesure'] = 'Your Moodle files have been changed, and you are about to automatically upgrade your server to this version:
<p><b>$a</b></p>
<p>Once you do this you can not go back again.</p>
<p>Are you sure you want to upgrade this server to this version?</p>';
$string['upgradinglogs'] = 'Upgrading logs';

?>
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// database to determine whether upgrades should
// be performed (see lib/db/*.php)

$version = 2004090300; // The current version is a date (YYYYMMDDXX)
$version = 2004090402; // The current version is a date (YYYYMMDDXX)

$release = "1.5 unstable development"; // User-friendly version number

Expand Down

0 comments on commit 6981792

Please sign in to comment.