Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: dispatch success message after transaction commits

Andras Bacsaiac14a327233a
diff --git a/app/Livewire/SharedVariables/Environment/Show.php b/app/Livewire/SharedVariables/Environment/Show.php
index 6b1d35d14b..328986cea0 100644
--- a/app/Livewire/SharedVariables/Environment/Show.php
+++ b/app/Livewire/SharedVariables/Environment/Show.php
@@ -99,10 +99,9 @@ class Show extends Component
private function handleBulkSubmit()
{
$variables = parseEnvFormatToArray($this->variables);
+ $changesMade = false;
- DB::transaction(function () use ($variables) {
- $changesMade = false;
-
+ DB::transaction(function () use ($variables, &$changesMade) {
// Delete removed variables
$deletedCount = $this->deleteRemovedVariables($variables);
if ($deletedCount > 0) {
@@ -114,11 +113,12 @@ class Show extends Component
if ($updatedCount > 0) {
$changesMade = true;
}
-
- if ($changesMade) {
- $this->dispatch('success', 'Environment variables updated.');
- }
});
+
+ // Only dispatch success after transaction has committed
+ if ($changesMade) {
+ $this->dispatch('success', 'Environment variables updated.');
+ }
}
private function deleteRemovedVariables($variables)