Skip to content
Browse files

Moodle can now upgrade itself, just like the modules do

  • Loading branch information...
1 parent dafa318 commit cbd1170e9130243be94e2cbcad98ccd544ed6c4c martin committed
Showing with 97 additions and 32 deletions.
  1. +2 −6 .htaccess
  2. +2 −6 README
  3. +0 −20 UPGRADES
  4. +31 −0 UPGRADING
  5. +35 −0 admin/index.php
  6. +27 −0 version.php
View
8 .htaccess
@@ -1,9 +1,5 @@
-WARNING: the CVS tree is currently a little unstable,
- as I'm doing some major work on the code.
+README $Id$
+------
- It may or may not work right now.
-
- Martin - 18 May 2002
-------------------------------------------------------
All the documention is in the "doc" subdirectory. :-)
View
8 README
@@ -1,9 +1,5 @@
-WARNING: the CVS tree is currently a little unstable,
- as I'm doing some major work on the code.
+README $Id$
+------
- It may or may not work right now.
-
- Martin - 18 May 2002
-------------------------------------------------------
All the documention is in the "doc" subdirectory. :-)
View
20 UPGRADES
@@ -1,20 +0,0 @@
-%Id%
-
-UPGRADING MOODLE
-----------------
-
-This file keeps track of changes to Moodle that may break
-installations. Whenever you upgrade the Moodle code from
-an earlier version (by CVS, for example), check this file
-to see if there is anything else you need to do to keep
-your Moodle installation humming smoothly.
-
----------------------------------------------------------
-
-
-
-4-7-2002 Added 'teacher' type to forum->type
-
-You can use this SQL command to update your forum table:
-
-ALTER TABLE `forum` CHANGE `type` `type` ENUM('discussion','news','social','general','eachuser','teacher') DEFAULT 'general' NOT NULL
View
31 UPGRADING
@@ -0,0 +1,31 @@
+UPGRADING $Id$
+---------
+
+Since the first main release of Moodle (2002080100)
+most upgrading is done automatically. See the file
+version.php for all the details.
+
+When upgrading from any previous version of Moodle,
+all you normally will need to do is this:
+
+1a) Update the source files using CVS
+
+ or
+
+1b) Make a backup of the current working installation
+ files, then put the new files here. Make sure you
+ copy your old config.php back here (or make a new
+ one by editing config-dist.php).
+
+2) Login as the admin user and visit /admin using a
+ web browser.
+
+If all goes well, your databases will be upgraded to
+suit the new files, and you can go on using Moodle
+normally.
+
+If you have problems, let me know.
+
+Cheers,
+Martin
+
View
35 admin/index.php
@@ -24,6 +24,41 @@
die;
}
+ // Check version of Moodle code on disk compared with database
+ // and upgrade if possible.
+
+ include_once("$CFG->dirroot/version.php"); # defines $version and upgrades
+
+ if ($dversion = get_field("config", "value", "name", "version")) {
+ if ($version > $dversion) { // upgrade
+ notify("Upgrading databases from version $dversion to $version...");
+ if (upgrade_moodle($dversion)) {
+ if (set_field("config", "value", "$version", "name", "version")) {
+ notify("Databases were successfully upgraded");
+ print_heading("<A HREF=\"index.php\">Continue</A>");
+ die;
+ } else {
+ notify("Upgrade failed! (Could not update version in config table)");
+ }
+ } else {
+ notify("Upgrade failed! See /version.php");
+ }
+ } else if ($version < $dversion) {
+ notify("WARNING!!! The code you are using is OLDER than the version that made these databases!");
+ }
+
+ } else {
+ $dversion->name = "version";
+ $dversion->value = $version;
+ if (insert_record("config", $dversion)) {
+ notify("You are currently using Moodle version $version");
+ print_heading("<A HREF=\"index.php\">Continue</A>");
+ die;
+ } else {
+ error("A problem occurred inserting current version into databases");
+ }
+ }
+
// Find and check all modules and load them up.
$dir = opendir("$CFG->dirroot/mod");
while ($mod = readdir($dir)) {
View
27 version.php
@@ -0,0 +1,27 @@
+<?PHP //$Id$
+// This file keeps track of upgrades to Moodle.
+//
+// Sometimes, changes between versions involve
+// alterations to database structures and other
+// major things that may break installations.
+//
+// This file specifies the current version of
+// Moodle installed, which can be compared against
+// a previous version (see the "config" table).
+//
+// To do this, visit the "admin" page.
+//
+// The upgrade function in this file will attempt
+// to perform all the necessary actions to upgrade
+// your older databases to the current version.
+// If there's something it cannot do itself, it
+// will tell you what you need to do.
+
+$version = 2002072704;
+
+function upgrade_moodle($oldversion) {
+
+ return true;
+}
+
+?>

0 comments on commit cbd1170

Please sign in to comment.
Something went wrong with that request. Please try again.