]> BookStack Code Mirror - system-cli/commitdiff
Fixed update-url command not ran, Fixed wrong env contents
authorDan Brown <redacted>
Sun, 7 May 2023 11:27:46 +0000 (12:27 +0100)
committerDan Brown <redacted>
Sun, 7 May 2023 11:29:40 +0000 (12:29 +0100)
- 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

src/Commands/RestoreCommand.php
tests/Commands/RestoreCommandTest.php

index ec83183060690d24e7383b212ad93bcfcb409cfc..84c7106d948eab47e43f8d7702f8db2742d2d1ac 100644 (file)
@@ -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", [
index df70d16ae1f14000ef0fbf70cfc333d5e21d3aab..bcb799226ea6ec91d1a158d6d5795abc3380f696 100644 (file)
@@ -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');