diff --git a/main/install/index.php b/main/install/index.php index 2603934fcf..0377145112 100755 --- a/main/install/index.php +++ b/main/install/index.php @@ -782,8 +782,6 @@ if (@$_POST['step2']) { $manager->getConnection()->executeQuery($sql); $envFile = api_get_path(SYS_PATH).'.env'; - $contents = file_get_contents($envFile); - $params = [ '{{DATABASE_HOST}}' => $dbHostForm, '{{DATABASE_PORT}}' => $dbPortForm, @@ -793,10 +791,8 @@ if (@$_POST['step2']) { '{{APP_INSTALLED}}' => 1, '{{APP_ENCRYPT_METHOD}}' => $encryptPassForm ]; - $contents = str_replace(array_keys($params), array_values($params), $contents); - file_put_contents($envFile, $contents); - - (new Dotenv())->load(api_get_path(SYS_PATH).'.env'); + updateEnvFile($params); + (new Dotenv())->load($envFile); $kernel = new Kernel('dev', true); $application = new Application($kernel); @@ -810,7 +806,6 @@ if (@$_POST['step2']) { $kernel->boot(); $doctrine = $kernel->getContainer()->get('doctrine'); $manager = $doctrine->getManager(); - $sysPath = api_get_path(SYS_PATH); finishInstallation( $manager, diff --git a/main/install/install.lib.php b/main/install/install.lib.php index ebc131c79a..86264f6d60 100755 --- a/main/install/install.lib.php +++ b/main/install/install.lib.php @@ -2722,6 +2722,17 @@ function fixIds(EntityManager $em) } } +/** + * @param array $params + */ +function updateEnvFile($params) +{ + $envFile = api_get_path(SYS_PATH).'.env'; + $contents = file_get_contents($envFile); + $contents = str_replace(array_keys($params), array_values($params), $contents); + file_put_contents($envFile, $contents); +} + /** * * After the schema was created (table creation), the function adds