From 06096486d4f5a2260e48f5c0cf5fd5af71f30964 Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 18 Oct 2011 00:18:21 -0700 Subject: hopefully solve db update issues bug #182 --- boot.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'boot.php') diff --git a/boot.php b/boot.php index 37c530e81..c2c1088e4 100644 --- a/boot.php +++ b/boot.php @@ -539,6 +539,8 @@ function check_config(&$a) { $current = intval(DB_UPDATE_VERSION); if(($stored < $current) && file_exists('update.php')) { + load_config('database'); + // We're reporting a different version than what is currently installed. // Run any existing update scripts to bring the database up to current. @@ -552,6 +554,21 @@ function check_config(&$a) { for($x = $stored; $x < $current; $x ++) { if(function_exists('update_' . $x)) { + + // There could be a lot of processes running or about to run. + // We want exactly one process to run the update command. + // So store the fact that we're taking responsibility + // after first checking to see if somebody else already has. + + // If the update fails or times-out completely you may need to + // delete the config entry to try again. + + if(get_config('database','update_' . $x)) + break; + set_config('database','update_' . $x, '1'); + + // call the specific update + $func = 'update_' . $x; $func($a); } -- cgit v1.2.3