From 06f986adb26b92caecb3a28588a0a5e152be9f3a Mon Sep 17 00:00:00 2001 From: Bogdan Date: Fri, 31 Jul 2026 01:09:43 +0200 Subject: [PATCH 1/2] fix: gracefully skip unreadable .env in Boot::loadDotEnv Test ResponseSendTest::testHeaderOverride fails when tests run in random order because the spawned process (#[RunInSeparateProcess]) calls Boot::loadDotEnv() -> DotEnv::parse(), which throws InvalidArgument- Exception when .env exists but is unreadable. The fix catches the exception in loadDotEnv() so .env errors are silently ignored - .env is optional. --- system/Boot.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/system/Boot.php b/system/Boot.php index a1b8c9695004..5405bbd9a034 100644 --- a/system/Boot.php +++ b/system/Boot.php @@ -22,6 +22,7 @@ use Config\Optimize; use Config\Paths; use Config\Services; +use InvalidArgumentException; /** * Bootstrap for the application @@ -206,7 +207,11 @@ protected static function loadDotEnv(Paths $paths): void { require_once $paths->systemDirectory . '/Config/DotEnv.php'; $envDirectory = $paths->envDirectory ?? $paths->appDirectory . '/../'; // @phpstan-ignore nullCoalesce.property - (new DotEnv($envDirectory))->load(); + + try { + (new DotEnv($envDirectory))->load(); + } catch (InvalidArgumentException) { + } } protected static function defineEnvironment(): void From d64a186d6ee209010530f843fe89f559629294c0 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Fri, 31 Jul 2026 01:17:48 +0200 Subject: [PATCH 2/2] fix: isolate test bootstrap from project .env file Set $paths->envDirectory to TESTPATH in the test bootstrap so that separate-process tests (#[RunInSeparateProcess]) look for .env in a controlled directory instead of the project root. This prevents crashes when a parallel test creates or modifies .env at the project root. --- system/Test/bootstrap.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/system/Test/bootstrap.php b/system/Test/bootstrap.php index d2b47aaf21fb..26ceaae6a1a1 100644 --- a/system/Test/bootstrap.php +++ b/system/Test/bootstrap.php @@ -77,6 +77,10 @@ * and fires up an environment-specific bootstrapping. */ +// Use a controlled environment directory for tests to avoid +// separate-process tests failing on an unreadable .env file. +$paths->envDirectory = TESTPATH; + // LOAD THE FRAMEWORK BOOTSTRAP FILE require $paths->systemDirectory . '/Boot.php'; Boot::bootTest($paths);