From 94cb6009866f4ebc16d92087c0440adb98f18299 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 6 Oct 2014 19:30:06 +0200 Subject: Use eventlog in init and update API, populate database with default values on init --- apis/update.inc.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'apis/update.inc.php') diff --git a/apis/update.inc.php b/apis/update.inc.php index 3c8984b6..4fb4b3fb 100644 --- a/apis/update.inc.php +++ b/apis/update.inc.php @@ -2,6 +2,12 @@ $targetVersion = Database::getExpectedSchemaVersion(); +function fatal($message) +{ + EventLog::failure($message); + die("$message\n"); +} + // ####################### $res = Database::queryFirst("SELECT value FROM property WHERE name = 'webif-version' LIMIT 1", array(), true); @@ -16,16 +22,16 @@ while ($currentVersion < $targetVersion) { $function = 'update_' . $currentVersion; if (!function_exists($function)) - die("Don't know how to update from version $currentVersion to $targetVersion :-("); + fatal("Don't know how to update from version $currentVersion to $targetVersion :-("); if (!$function()) - die("Update from $currentVersion to $targetVersion failed! :-("); + fatal("Update from $currentVersion to $targetVersion failed! :-("); $currentVersion++; $ret = Database::exec("INSERT INTO property (name, value) VALUES ('webif-version', :version) ON DUPLICATE KEY UPDATE value = VALUES(value)", array('version' => $currentVersion), false); if ($ret === false) - die('Writing version information back to DB failed. Next update will probably break.'); + fatal('Writing version information back to DB failed. Next update will probably break.'); if ($currentVersion < $targetVersion) { echo("Updated to $currentVersion...\n"); -- cgit v1.2.3-55-g7522