aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/version.php
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-10-07 11:38:32 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-10-07 11:38:32 +0000
commit1c9fafbf3b817ae6fb038c1f25f9e4fd817df929 (patch)
tree4e11280242c2bcfdba7d74d51802e924b62fb5b7 /engine/lib/version.php
parentf89ef0c9768871d42529ec81d2ec8e14565d6c71 (diff)
downloadelgg-1c9fafbf3b817ae6fb038c1f25f9e4fd817df929.tar.gz
elgg-1c9fafbf3b817ae6fb038c1f25f9e4fd817df929.tar.bz2
Closes #409: PHP update script to update core added
git-svn-id: https://code.elgg.org/elgg/trunk@2208 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/version.php')
-rw-r--r--engine/lib/version.php65
1 files changed, 61 insertions, 4 deletions
diff --git a/engine/lib/version.php b/engine/lib/version.php
index 58f3cbde6..4799b1a85 100644
--- a/engine/lib/version.php
+++ b/engine/lib/version.php
@@ -9,7 +9,58 @@
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
* @copyright Curverider Ltd 2008
* @link http://elgg.org/
- */
+ */
+
+ /**
+ * Run any php upgrade scripts which are required
+ *
+ * @param unknown_type $version
+ */
+ function upgrade_code($version)
+ {
+ global $CONFIG;
+
+ // Elgg and its database must be installed to upgrade it!
+ if (!is_db_installed() || !is_installed()) return false;
+
+ $version = (int) $version;
+
+ if ($handle = opendir($CONFIG->path . 'engine/lib/upgrades/')) {
+
+ $upgrades = array();
+
+ while ($updatefile = readdir($handle)) {
+
+ // Look for upgrades and add to upgrades list
+ if (!is_dir($CONFIG->path . 'engine/lib/upgrades/' . $updatefile)) {
+ if (preg_match('/([0-9]*)\.php/',$updatefile,$matches)) {
+ $core_version = (int) $matches[1];
+ if ($core_version > $version) {
+ $upgrades[] = $updatefile;
+ }
+ }
+ }
+
+ }
+
+ // Sort and execute
+ asort($upgrades);
+ if (sizeof($upgrades) > 0) {
+ foreach($upgrades as $upgrade) {
+ try {
+ @include($CONFIG->path . 'engine/lib/upgrades/' . $upgrade);
+ } catch (Exception $e) {
+ error_log($e->getmessage());
+ }
+
+ }
+ }
+
+ return true;
+ }
+
+ return false;
+ }
/**
* Get the current version information
@@ -53,11 +104,17 @@
function version_upgrade() {
$dbversion = (int) datalist_get('version');
+
+ // Upgrade database
db_upgrade($dbversion);
+ system_message(elgg_echo('upgrade:db'));
+
+ // Upgrade core
+ if (upgrade_code($dbversion))
+ system_message(elgg_echo('upgrade:core'));
+
+ // Update the version
datalist_set('version', get_version());
- system_message(elgg_echo('upgrade:db'));
- //forward();
- //exit;
}