mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #7510 from open-sausages/pulls/4.0/fix-installer-env
BUG Fix env loading in installer
This commit is contained in:
commit
2f64bfcd65
@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
namespace SilverStripe\Dev\Install;
|
namespace SilverStripe\Dev\Install;
|
||||||
|
|
||||||
use Dotenv\Dotenv;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use SilverStripe\Control\Cookie;
|
use SilverStripe\Control\Cookie;
|
||||||
use SilverStripe\Control\HTTPApplication;
|
use SilverStripe\Control\HTTPApplication;
|
||||||
use SilverStripe\Control\HTTPRequest;
|
use SilverStripe\Control\HTTPRequest;
|
||||||
use SilverStripe\Control\HTTPRequestBuilder;
|
use SilverStripe\Control\HTTPRequestBuilder;
|
||||||
use SilverStripe\Core\CoreKernel;
|
use SilverStripe\Core\CoreKernel;
|
||||||
|
use SilverStripe\Core\EnvironmentLoader;
|
||||||
use SilverStripe\Core\Kernel;
|
use SilverStripe\Core\Kernel;
|
||||||
use SilverStripe\Core\Startup\ParameterConfirmationToken;
|
use SilverStripe\Core\Startup\ParameterConfirmationToken;
|
||||||
use SilverStripe\ORM\DatabaseAdmin;
|
use SilverStripe\ORM\DatabaseAdmin;
|
||||||
@ -234,14 +234,9 @@ PHP;
|
|||||||
$vars = [];
|
$vars = [];
|
||||||
|
|
||||||
// Retain existing vars
|
// Retain existing vars
|
||||||
// Note: vars with # or " in them are discarded
|
$env = new EnvironmentLoader();
|
||||||
if (file_exists($path)) {
|
if (file_exists($path)) {
|
||||||
$env = new Dotenv($this->getBaseDir());
|
$vars = $env->loadFile($path) ?: [];
|
||||||
foreach ($env->load() as $line) {
|
|
||||||
if (preg_match('/^(?<key>\w+)\s*=\s*("?)(?<value>[^"#]*)("?)$/', $line, $matches)) {
|
|
||||||
$vars[$matches['key']] = $matches['value'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set base URL
|
// Set base URL
|
||||||
@ -288,8 +283,7 @@ PHP;
|
|||||||
$this->writeToFile('.env', implode("\n", $lines));
|
$this->writeToFile('.env', implode("\n", $lines));
|
||||||
|
|
||||||
// Re-load env vars for installer access
|
// Re-load env vars for installer access
|
||||||
$path = $this->getBaseDir();
|
$env->loadFile($path);
|
||||||
(new Dotenv($path))->load();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user