From 3c7c44adda9f434495f039d7aa0fe1ed4e63dbe6 Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Mon, 4 Sep 2023 10:08:50 -0700 Subject: [PATCH] Fix _APP_EXECUTOR_HOST for upgrades As of 1.4.0, the hostname of the executor should be executor rather than appwrite-executor. The problem is our install command always uses the existing installation's variable values as the default for the upgrade. This means the _APP_EXECUTOR_HOST will retain it's old value. This PR Adds an overwrite key to variables.php to allow overwriting the variable value regardless of whatever was in the previous installation. --- app/config/variables.php | 1 + src/Appwrite/Platform/Tasks/Install.php | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/config/variables.php b/app/config/variables.php index b39eb9c41d..8d31ee350b 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -750,6 +750,7 @@ return [ 'introduction' => '0.13.0', 'default' => 'http://appwrite-executor/v1', 'required' => false, + 'overwrite' => true, 'question' => '', 'filter' => '' ], diff --git a/src/Appwrite/Platform/Tasks/Install.php b/src/Appwrite/Platform/Tasks/Install.php index c9ed1d733e..89297a78ed 100644 --- a/src/Appwrite/Platform/Tasks/Install.php +++ b/src/Appwrite/Platform/Tasks/Install.php @@ -40,6 +40,7 @@ class Install extends Action $config = Config::getParam('variables'); $defaultHTTPPort = '80'; $defaultHTTPSPort = '443'; + /** @var array> $vars array whre key is variable name and value is variable */ $vars = []; /** @@ -50,7 +51,7 @@ class Install extends Action foreach ($config as $category) { foreach ($category['variables'] ?? [] as $var) { - $vars[] = $var; + $vars[$var['name']] = $var; } } @@ -104,10 +105,10 @@ class Install extends Action if (is_null($value)) { continue; } - foreach ($vars as $i => $var) { - if ($var['name'] === $key) { - $vars[$i]['default'] = $value; - } + + $configVar = $vars[$key] ?? []; + if (!empty($configVar) && !($configVar['overwrite'] ?? false)) { + $vars[$key]['default'] = $value; } } } @@ -123,10 +124,10 @@ class Install extends Action if (is_null($value)) { continue; } - foreach ($vars as $i => $var) { - if ($var['name'] === $key) { - $vars[$i]['default'] = $value; - } + + $configVar = $vars[$key] ?? []; + if (!empty($configVar) && !($configVar['overwrite'] ?? false)) { + $vars[$key]['default'] = $value; } } }