From 91f6c61fcdfa6d0665384c323abe55f1da2ea073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Thu, 16 Oct 2025 01:09:53 +0200 Subject: [PATCH] Fix assert: run createDatabase() outside assert() assert() calls, including assert(foo()), can be entirely compiled out depending on the INI settings described here: https://www.php.net/manual/en/function.assert.php That in turn means even side effects of foo() can be entirely compiled out. Therefore, to ensure the call actually runs, we need to run it before the assert(), store its return value, and only then make assertions about the return value. --- src/Jobs/CreateDatabase.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Jobs/CreateDatabase.php b/src/Jobs/CreateDatabase.php index 6cd035dc..decdb445 100644 --- a/src/Jobs/CreateDatabase.php +++ b/src/Jobs/CreateDatabase.php @@ -40,7 +40,8 @@ class CreateDatabase implements ShouldQueue try { $databaseManager->ensureTenantCanBeCreated($this->tenant); - assert($this->tenant->database()->manager()->createDatabase($this->tenant) === true); + $databaseCreated = $this->tenant->database()->manager()->createDatabase($this->tenant); + assert($databaseCreated); event(new DatabaseCreated($this->tenant)); } catch (TenantDatabaseAlreadyExistsException | TenantDatabaseUserAlreadyExistsException $e) {