From: Dan Brown Date: Sun, 7 May 2023 11:27:46 +0000 (+0100) Subject: Fixed update-url command not ran, Fixed wrong env contents X-Git-Url: http://source.bookstackapp.com/system-cli/commitdiff_plain/69541a611d1148c005178d1a2ee40bcc4e72fcfe Fixed update-url command not ran, Fixed wrong env contents - Adds --force command to the update-url run so that it's actually ran during a restore. Option recently added on BookStack side to support. - Updates env handling so that the old env contents are actually used as part of the merge. Updated existing test to cover. Fixes #7, Fixes #8 --- diff --git a/src/Commands/RestoreCommand.php b/src/Commands/RestoreCommand.php index ec83183..84c7106 100644 --- a/src/Commands/RestoreCommand.php +++ b/src/Commands/RestoreCommand.php @@ -146,7 +146,7 @@ class RestoreCommand extends Command $currentEnvDbLines = array_values(array_filter(explode("\n", $currentEnvContents), function (string $line) { return str_starts_with($line, 'DB_'); })); - $oldEnvLines = array_values(array_filter(explode("\n", $currentEnvContents), function (string $line) { + $oldEnvLines = array_values(array_filter(explode("\n", $envContents), function (string $line) { return !str_starts_with($line, 'DB_'); })); $envContents = implode("\n", [ diff --git a/tests/Commands/RestoreCommandTest.php b/tests/Commands/RestoreCommandTest.php index df70d16..bcb7992 100644 --- a/tests/Commands/RestoreCommandTest.php +++ b/tests/Commands/RestoreCommandTest.php @@ -47,6 +47,9 @@ class RestoreCommandTest extends TestCase $this->assertStringEqualsFile('/var/www/bookstack-restore/public/uploads/test.txt', 'hello-public-uploads'); $this->assertStringEqualsFile('/var/www/bookstack-restore/storage/uploads/test.txt', 'hello-storage-uploads'); $this->assertStringEqualsFile('/var/www/bookstack-restore/themes/test.txt', 'hello-themes'); + $env = file_get_contents('/var/www/bookstack-restore/.env'); + $this->assertStringContainsString('APP_KEY=abc123', $env); + $this->assertStringContainsString('APP_URL=https://example.com', $env); $mysql->query("DROP TABLE zz_testing;"); exec('rm -rf /var/www/bookstack-restore');