From e03189fe87cbea736597ba8f65226bb5d0aadbbf Mon Sep 17 00:00:00 2001 From: sumaiazaman Date: Sun, 27 Sep 2026 14:54:18 +0600 Subject: [PATCH 1/2] Add test for report helpers without a log level --- .../Foundation/FoundationHelpersTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/Integration/Foundation/FoundationHelpersTest.php b/tests/Integration/Foundation/FoundationHelpersTest.php index f0231c9358ba..e4e268c0ef77 100644 --- a/tests/Integration/Foundation/FoundationHelpersTest.php +++ b/tests/Integration/Foundation/FoundationHelpersTest.php @@ -26,6 +26,19 @@ public function testReportHelpersForwardContextAndLevel() $this->assertSame([LogLevel::WARNING, LogLevel::NOTICE, LogLevel::INFO], $handler->levels); } + public function testReportHelpersOnlyForwardLevelWhenGiven() + { + $exception = new Exception('Test'); + + $this->mock(ExceptionHandler::class, function ($mock) use ($exception) { + $mock->expects('report')->times(3)->withArgs(fn (...$arguments) => $arguments === [$exception, ['id' => 1]]); + }); + + report($exception, ['id' => 1]); + report_if(true, $exception, ['id' => 1]); + report_unless(false, $exception, ['id' => 1]); + } + public function testRescue() { $this->assertSame( From b54fd56452967dd8f30220227ebb092c5e812c51 Mon Sep 17 00:00:00 2001 From: sumaiazaman Date: Sun, 27 Sep 2026 14:54:19 +0600 Subject: [PATCH 2/2] Only pass the log level to the exception handler when one is given --- src/Illuminate/Foundation/helpers.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Illuminate/Foundation/helpers.php b/src/Illuminate/Foundation/helpers.php index ea4022d4a5f8..dd49ac073ea0 100644 --- a/src/Illuminate/Foundation/helpers.php +++ b/src/Illuminate/Foundation/helpers.php @@ -728,6 +728,12 @@ function report($exception, array $context = [], ?string $level = null): void $exception = new Exception($exception); } + if (is_null($level)) { + app(ExceptionHandler::class)->report($exception, $context); + + return; + } + app(ExceptionHandler::class)->report($exception, $context, $level); } }