From edb6072146ac857a48481466176786e07ccf5316 Mon Sep 17 00:00:00 2001 From: Eric Paulson Date: Mon, 29 Mar 2021 20:42:10 -0500 Subject: [PATCH] Patch issue with environment database password replacement This update fixes an issue that is caused if you already have a DB_PASSWORD configured in your .env. Prior to this change, if you have this (for example): ``` DB_PASSWORD=mypassword ``` After running `sail:install` it would then look like this: ``` DB_PASSWORD=passwordmypassword ``` And each time you run `sail install` it'll keep growing. This is because only DB_PASSWORD= is being replaced, when it should be replacing the password as well, which can be accomplished using `preg_replace` and a simple regex as in this PR. --- src/Console/InstallCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php index b00afc55..1c190862 100644 --- a/src/Console/InstallCommand.php +++ b/src/Console/InstallCommand.php @@ -120,7 +120,7 @@ protected function replaceEnvVariables(array $services) } $environment = str_replace('DB_USERNAME=root', "DB_USERNAME=sail", $environment); - $environment = str_replace('DB_PASSWORD=', "DB_PASSWORD=password", $environment); + $environment = preg_replace("/DB_PASSWORD=(.*)/", "DB_PASSWORD=password", $environment); $environment = str_replace('MEMCACHED_HOST=127.0.0.1', 'MEMCACHED_HOST=memcached', $environment); $environment = str_replace('REDIS_HOST=127.0.0.1', 'REDIS_HOST=redis', $environment);