Skip to content
This repository was archived by the owner on Jul 26, 2024. It is now read-only.

Commit 69541a6

Browse files
committed
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
1 parent 16b09ea commit 69541a6

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/Commands/RestoreCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ protected function restoreEnv(string $extractDir, string $appDir, OutputInterfac
146146
$currentEnvDbLines = array_values(array_filter(explode("\n", $currentEnvContents), function (string $line) {
147147
return str_starts_with($line, 'DB_');
148148
}));
149-
$oldEnvLines = array_values(array_filter(explode("\n", $currentEnvContents), function (string $line) {
149+
$oldEnvLines = array_values(array_filter(explode("\n", $envContents), function (string $line) {
150150
return !str_starts_with($line, 'DB_');
151151
}));
152152
$envContents = implode("\n", [

tests/Commands/RestoreCommandTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ public function test_restore_into_cwd_by_default_with_all_content_types()
4747
$this->assertStringEqualsFile('/var/www/bookstack-restore/public/uploads/test.txt', 'hello-public-uploads');
4848
$this->assertStringEqualsFile('/var/www/bookstack-restore/storage/uploads/test.txt', 'hello-storage-uploads');
4949
$this->assertStringEqualsFile('/var/www/bookstack-restore/themes/test.txt', 'hello-themes');
50+
$env = file_get_contents('/var/www/bookstack-restore/.env');
51+
$this->assertStringContainsString('APP_KEY=abc123', $env);
52+
$this->assertStringContainsString('APP_URL=https://example.com', $env);
5053

5154
$mysql->query("DROP TABLE zz_testing;");
5255
exec('rm -rf /var/www/bookstack-restore');

0 commit comments

Comments
 (0)