aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib/DB_Upgrade.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-03-25 13:22:14 -0700
committerMario Vavti <mario@mariovavti.com>2017-03-31 10:26:44 +0200
commit57a8b3f85779d91c23855f7459622bce9ce89d55 (patch)
treef04184ab56ea677528a754ce719fc160438c046a /Zotlabs/Lib/DB_Upgrade.php
parent6e5a06421f7c841718196ac9e80d4b0c5221ce6a (diff)
downloadvolse-hubzilla-57a8b3f85779d91c23855f7459622bce9ce89d55.tar.gz
volse-hubzilla-57a8b3f85779d91c23855f7459622bce9ce89d55.tar.bz2
volse-hubzilla-57a8b3f85779d91c23855f7459622bce9ce89d55.zip
provide compatibility with old-style update system
Diffstat (limited to 'Zotlabs/Lib/DB_Upgrade.php')
-rw-r--r--Zotlabs/Lib/DB_Upgrade.php22
1 files changed, 16 insertions, 6 deletions
diff --git a/Zotlabs/Lib/DB_Upgrade.php b/Zotlabs/Lib/DB_Upgrade.php
index 2ee29c314..55c69bcca 100644
--- a/Zotlabs/Lib/DB_Upgrade.php
+++ b/Zotlabs/Lib/DB_Upgrade.php
@@ -5,13 +5,25 @@ namespace Zotlabs\Lib;
class DB_Upgrade {
+ public $config_name = '';
+ public $func_prefix = '';
function __construct($db_revision) {
+ $update_file = 'install/' . PLATFORM_NAME . '/update.php';
+ if(! file_exists($update_file)) {
+ $update_file = 'install/update.php';
+ $this->config_name = 'db_version';
+ $this->func_prefix = 'update_r';
+ }
+ else {
+ $this->config_name = PLATFORM_NAME . '_db_version';
+ $this->func_prefix = PLATFORM_NAME . '_update_';
+ }
- $build = get_config('system', PLATFORM_NAME . '_db_version', 0);
+ $build = get_config('system', $this->config_name, 0);
if(! intval($build))
- $build = set_config('system', PLATFORM_NAME . '_db_version', $db_revision);
+ $build = set_config('system', $this->config_name, $db_revision);
if($build == $db_revision) {
// Nothing to be done.
@@ -26,8 +38,6 @@ class DB_Upgrade {
$current = intval($db_revision);
- $update_file = 'install/' . PLATFORM_NAME . '/update.php';
-
if(($stored < $current) && file_exists($update_file)) {
Config::Load('database');
@@ -43,7 +53,7 @@ class DB_Upgrade {
if($db_revision == UPDATE_VERSION) {
for($x = $stored; $x < $current; $x ++) {
- $func = PLATFORM_NAME . '_update_' . $x;
+ $func = $this->func_prefix . $x;
if(function_exists($func)) {
// There could be a lot of processes running or about to run.
// We want exactly one process to run the update command.
@@ -101,7 +111,7 @@ class DB_Upgrade {
}
}
}
- set_config('system', PLATFORM_NAME . '_db_version', $db_revision);
+ set_config('system', $this->config_name, $db_revision);
}
}
}