FIX: Update database_restorer to avoid shell use (#12731)

FIX: Update database_restorer to avoid shell use (#12731)

Follow-up to 0ec5fd5262647633399e856b0fba93735f6d6c11

diff --git a/lib/backup_restore/database_restorer.rb b/lib/backup_restore/database_restorer.rb
index 2ffe09e..100a366 100644
--- a/lib/backup_restore/database_restorer.rb
+++ b/lib/backup_restore/database_restorer.rb
@@ -136,7 +136,7 @@ module BackupRestore
           "SKIP_OPTIMIZE_ICONS" => "1",
           "DISABLE_TRANSLATION_OVERRIDES" => "1"
         },
-        "rake db:migrate",
+        "rake", "db:migrate",
         failure_message: "Failed to migrate database.",
         chdir: Rails.root
       )
diff --git a/spec/lib/backup_restore/database_restorer_spec.rb b/spec/lib/backup_restore/database_restorer_spec.rb
index a11c8cc..351406e 100644
--- a/spec/lib/backup_restore/database_restorer_spec.rb
+++ b/spec/lib/backup_restore/database_restorer_spec.rb
@@ -35,11 +35,11 @@ describe BackupRestore::DatabaseRestorer do
   end
 
   def expect_db_migrate
-    Discourse::Utils.expects(:execute_command).with do |env, command, options|
+    Discourse::Utils.expects(:execute_command).with do |env, *command, **options|
       env["SKIP_POST_DEPLOYMENT_MIGRATIONS"] == "0" &&
         env["SKIP_OPTIMIZE_ICONS"] == "1" &&
         env["DISABLE_TRANSLATION_OVERRIDES"] == "1" &&
-        command == "rake db:migrate" &&
+        command == ["rake", "db:migrate"] &&
         options[:chdir] == Rails.root
     end.once
   end

GitHub sha: 3436fef5

1 Like

This commit appears in #12731 which was approved by romanrizzi. It was merged by davidtaylorhq.

This commit has been mentioned on Discourse Meta. There might be relevant details there: