From 11a4702b10f4301e9e53b59e2aa00230037d9586 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Tue, 8 Oct 2024 08:57:51 +0200 Subject: [PATCH] Promote installer config options as env vars explicitly --- composer.json | 2 +- config/config.php | 5 ----- config/container.php | 13 ++++++++----- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index 77fc84a89..5f7078df7 100644 --- a/composer.json +++ b/composer.json @@ -45,7 +45,7 @@ "ramsey/uuid": "^4.7", "shlinkio/doctrine-specification": "^2.1.1", "shlinkio/shlink-common": "^6.3", - "shlinkio/shlink-config": "^3.0", + "shlinkio/shlink-config": "dev-main#76a96ee as 3.1", "shlinkio/shlink-event-dispatcher": "^4.1", "shlinkio/shlink-importer": "^5.3.2", "shlinkio/shlink-installer": "^9.2", diff --git a/config/config.php b/config/config.php index 78fc542a5..40f88ea3e 100644 --- a/config/config.php +++ b/config/config.php @@ -8,18 +8,13 @@ use Laminas\Diactoros; use Mezzio; use Mezzio\ProblemDetails; -use Shlinkio\Shlink\Config\ConfigAggregator\EnvVarLoaderProvider; use function Shlinkio\Shlink\Config\env; -use function Shlinkio\Shlink\Core\enumValues; $isTestEnv = env('APP_ENV') === 'test'; return (new ConfigAggregator\ConfigAggregator( providers: [ - ! $isTestEnv - ? new EnvVarLoaderProvider('config/params/generated_config.php', enumValues(Core\Config\EnvVars::class)) - : new ConfigAggregator\ArrayProvider([]), Mezzio\ConfigProvider::class, Mezzio\Router\ConfigProvider::class, Mezzio\Router\FastRouteRouter\ConfigProvider::class, diff --git a/config/container.php b/config/container.php index 6e5172a43..13d643534 100644 --- a/config/container.php +++ b/config/container.php @@ -6,13 +6,20 @@ use Shlinkio\Shlink\Core\Config\EnvVars; use Symfony\Component\Lock; +use function Shlinkio\Shlink\Config\loadEnvVarsFromConfig; +use function Shlinkio\Shlink\Core\enumValues; + use const Shlinkio\Shlink\LOCAL_LOCK_FACTORY; chdir(dirname(__DIR__)); require 'vendor/autoload.php'; -// This is one of the first files loaded. Configure the timezone here +// Promote env vars from installer config +loadEnvVarsFromConfig('config/params/generated_config.php', enumValues(EnvVars::class)); + +// This is one of the first files loaded. Configure the timezone and memory limit here +ini_set('memory_limit', EnvVars::MEMORY_LIMIT->loadFromEnv('512M')); date_default_timezone_set(EnvVars::TIMEZONE->loadFromEnv(date_default_timezone_get())); // This class alias tricks the ConfigAbstractFactory to return Lock\Factory instances even with a different service name @@ -23,10 +30,6 @@ class_alias(Lock\LockFactory::class, LOCAL_LOCK_FACTORY); return (static function (): ServiceManager { $config = require __DIR__ . '/config.php'; - - // Set memory limit right after loading config, to ensure installer config has been promoted as env vars - ini_set('memory_limit', EnvVars::MEMORY_LIMIT->loadFromEnv('512M')); - $container = new ServiceManager($config['dependencies']); $container->setService('config', $config);