From acaafa7f5095ad27afde85cd0622912c8221a1e5 Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Wed, 16 Aug 2017 08:54:12 -0300 Subject: Check if specific config upgrade code already ran and skip it --- src/etc/inc/config.lib.inc | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'src/etc') diff --git a/src/etc/inc/config.lib.inc b/src/etc/inc/config.lib.inc index 5d0216e..6c3fa8f 100644 --- a/src/etc/inc/config.lib.inc +++ b/src/etc/inc/config.lib.inc @@ -349,17 +349,30 @@ function convert_config() { if (file_exists("/etc/inc/upgrade_config_custom.inc")) { include_once("upgrade_config_custom.inc"); } + + if (!is_array($config['system']['already_run_config_upgrade'])) { + $config['system']['already_run_config_upgrade'] = array(); + } + $already_run =& $config['system']['already_run_config_upgrade']; + /* Loop and run upgrade_VER_to_VER() until we're at current version */ while ($config['version'] < $g['latest_config']) { $cur = $config['version'] * 10; $next = $cur + 1; - $migration_function = sprintf('upgrade_%03d_to_%03d', $cur, $next); - if (function_exists($migration_function)) { - $migration_function(); - } - $migration_function = "{$migration_function}_custom"; - if (function_exists($migration_function)) { - $migration_function(); + $migration_function = sprintf('upgrade_%03d_to_%03d', $cur, + $next); + + foreach (array("", "_custom") as $suffix) { + $migration_function .= $suffix; + if (!function_exists($migration_function)) { + continue; + } + if (isset($already_run[$migration_function])) { + /* Already executed, skip now */ + unset($already_run[$migration_function]); + } else { + $migration_function(); + } } $config['version'] = sprintf('%.1f', $next / 10); if (platform_booting()) { -- cgit v1.1