aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/version.php
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-09-23 17:27:09 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-09-23 17:27:09 +0000
commitb35e8cbe9e9776d86be034365c1033b61497bbb0 (patch)
tree10072e2ac96e2f0c1a969782c603986f3209fad6 /engine/lib/version.php
parent2d0bd94c643add43312294bab13789b16461878a (diff)
downloadelgg-b35e8cbe9e9776d86be034365c1033b61497bbb0.tar.gz
elgg-b35e8cbe9e9776d86be034365c1033b61497bbb0.tar.bz2
The database schema will now automatically update itself on upgrade.
git-svn-id: https://code.elgg.org/elgg/trunk@2107 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/version.php')
-rw-r--r--engine/lib/version.php36
1 files changed, 33 insertions, 3 deletions
diff --git a/engine/lib/version.php b/engine/lib/version.php
index ee707ca1d..405237298 100644
--- a/engine/lib/version.php
+++ b/engine/lib/version.php
@@ -21,7 +21,7 @@
global $CONFIG;
if (@include($CONFIG->path . "version.php")) {
- if ($humanreadable) return $version;
+ if (!$humanreadable) return $version;
return $release;
}
@@ -34,9 +34,9 @@
*
* @return true|false Depending on whether or not the db version matches the code version
*/
- function db_upgrade_check() {
+ function version_upgrade_check() {
- $dbversion = (int) get_datalist('version');
+ $dbversion = (int) datalist_get('version');
$version = get_version();
if ($version > $dbversion) {
@@ -45,5 +45,35 @@
return false;
}
+
+ /**
+ * Upgrades Elgg
+ *
+ */
+ function version_upgrade() {
+
+ $dbversion = (int) datalist_get('version');
+ db_upgrade($dbversion);
+ datalist_set('version', get_version());
+ system_message(elgg_echo('upgrade:db'));
+ forward();
+ exit;
+
+ }
+
+ /**
+ * Runs an upgrade check on boot.
+ *
+ */
+ function version_boot() {
+
+ if (version_upgrade_check()) {
+ version_upgrade();
+ }
+
+ }
+
+ // Register the boot handler for version
+ register_elgg_event_handler("boot","system","version_boot");
?> \ No newline at end of file