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(livewire): scope DatabaseProxyStopped to proxy fields, harden status trait

Aditya Tripathi7a3fcd37d5b5
diff --git a/app/Livewire/Project/Database/Clickhouse/General.php b/app/Livewire/Project/Database/Clickhouse/General.php
index b5c0ffff40..8573009266 100644
--- a/app/Livewire/Project/Database/Clickhouse/General.php
+++ b/app/Livewire/Project/Database/Clickhouse/General.php
@@ -192,9 +192,12 @@ class General extends Component
}
}
- public function databaseProxyStopped()
+ public function databaseProxyStopped(): void
{
- $this->syncData();
+ $this->database->refresh();
+ $this->isPublic = $this->database->is_public;
+ $this->publicPort = $this->database->public_port;
+ $this->publicPortTimeout = $this->database->public_port_timeout;
$this->dispatch('databaseUpdated');
}
diff --git a/app/Livewire/Project/Database/Dragonfly/General.php b/app/Livewire/Project/Database/Dragonfly/General.php
index 5f57693b1d..01a474761e 100644
--- a/app/Livewire/Project/Database/Dragonfly/General.php
+++ b/app/Livewire/Project/Database/Dragonfly/General.php
@@ -184,9 +184,12 @@ class General extends Component
}
}
- public function databaseProxyStopped()
+ public function databaseProxyStopped(): void
{
- $this->syncData();
+ $this->database->refresh();
+ $this->isPublic = $this->database->is_public;
+ $this->publicPort = $this->database->public_port;
+ $this->publicPortTimeout = $this->database->public_port_timeout;
$this->dispatch('databaseUpdated');
}
diff --git a/app/Livewire/Project/Database/Keydb/General.php b/app/Livewire/Project/Database/Keydb/General.php
index 1c5c828a3a..6031cb7ac1 100644
--- a/app/Livewire/Project/Database/Keydb/General.php
+++ b/app/Livewire/Project/Database/Keydb/General.php
@@ -189,9 +189,12 @@ class General extends Component
}
}
- public function databaseProxyStopped()
+ public function databaseProxyStopped(): void
{
- $this->syncData();
+ $this->database->refresh();
+ $this->isPublic = $this->database->is_public;
+ $this->publicPort = $this->database->public_port;
+ $this->publicPortTimeout = $this->database->public_port_timeout;
$this->dispatch('databaseUpdated');
}
diff --git a/app/Traits/HasDatabaseStatusInfo.php b/app/Traits/HasDatabaseStatusInfo.php
index 98c939b7ee..e46cccf0c0 100644
--- a/app/Traits/HasDatabaseStatusInfo.php
+++ b/app/Traits/HasDatabaseStatusInfo.php
@@ -5,6 +5,7 @@ namespace App\Traits;
use App\Helpers\SslHelper;
use Carbon\Carbon;
use Exception;
+use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Auth;
/**
@@ -51,16 +52,23 @@ trait HasDatabaseStatusInfo
return false;
}
- public function getListeners()
+ public function getListeners(): array
{
- $userId = Auth::id();
- $teamId = Auth::user()->currentTeam()->id;
-
- return [
- "echo-private:user.{$userId},DatabaseStatusChanged" => 'refresh',
- "echo-private:team.{$teamId},ServiceChecked" => 'refresh',
- 'databaseUpdated' => 'refresh',
- ];
+ $listeners = ['databaseUpdated' => 'refresh'];
+
+ $user = Auth::user();
+ if (! $user) {
+ return $listeners;
+ }
+
+ $listeners["echo-private:user.{$user->id},DatabaseStatusChanged"] = 'refresh';
+
+ $team = $user->currentTeam();
+ if ($team) {
+ $listeners["echo-private:team.{$team->id},ServiceChecked"] = 'refresh';
+ }
+
+ return $listeners;
}
public function mount(): void
@@ -150,7 +158,7 @@ trait HasDatabaseStatusInfo
}
}
- public function render()
+ public function render(): View
{
return view('livewire.project.database.status-info', [
'label' => $this->databaseLabel(),
diff --git a/tests/Feature/DatabaseSslStatusRefreshTest.php b/tests/Feature/DatabaseSslStatusRefreshTest.php
index 7b0e4c0a34..7efb037891 100644
--- a/tests/Feature/DatabaseSslStatusRefreshTest.php
+++ b/tests/Feature/DatabaseSslStatusRefreshTest.php
@@ -78,11 +78,13 @@ it('does not subscribe the form to status broadcasts when display lives in a sib
->not->toHaveKey("echo-private:team.{$this->team->id},ServiceStatusChanged");
})->with('database-general-forms-without-broadcasts');
+/**
+ * Resolve a Livewire component's listeners regardless of whether the subclass
+ * exposes getListeners() publicly or only declares a $listeners array — the
+ * HandlesEvents trait keeps getListeners() protected by default.
+ */
function resolveLivewireListeners(object $component): array
{
- // Livewire's HandlesEvents trait declares getListeners() as protected,
- // so subclasses that override it as public are callable directly, but
- // subclasses that rely on $listeners are not. Reflection handles both.
$method = new ReflectionMethod($component, 'getListeners');
$method->setAccessible(true);