Add validation in array when editing the .env file

pull/2881/head
Julio Montoya 6 years ago
parent daa0ee8296
commit 03dcd30d84
  1. 1
      .env.dist
  2. 17
      main/install/install.lib.php

@ -36,6 +36,7 @@ APP_ENCRYPT_METHOD={{APP_ENCRYPT_METHOD}}
APP_LOCALE=en
## Example: '/chamilo2'
APP_URL_APPEND="{{APP_URL_APPEND}}"
APP_MULTIPLE_ACCESS_URL=""

@ -2975,6 +2975,23 @@ function fixLpId($connection, $debug)
*/
function updateEnvFile($distFile, $envFile, $params)
{
$requirements = [
'DATABASE_HOST',
'DATABASE_PORT',
'DATABASE_NAME',
'DATABASE_USER',
'DATABASE_PASSWORD',
'APP_INSTALLED',
'APP_ENCRYPT_METHOD',
'APP_URL_APPEND',
];
foreach ($requirements as $requirement) {
if (!isset($params[$requirement])) {
throw new \Exception("The parameter $requirement is needed in order to edit the .env file");
}
}
$contents = file_get_contents($distFile);
$contents = str_replace(array_keys($params), array_values($params), $contents);
file_put_contents($envFile, $contents);

Loading…
Cancel
Save