Skip to content

[14.x] Fix report() passing a null log level to the exception handler - #61750

Merged
taylorotwell merged 2 commits into
laravel:masterfrom
sumaiazaman:14.x-fix-report-helper-passing-null-level
Sep 27, 2026
Merged

taylorotwell merged 2 commits into
laravel:masterfrom
sumaiazaman:14.x-fix-report-helper-passing-null-level

Conversation

@sumaiazaman

Copy link
Copy Markdown
Contributor

Since #61694 the report() helper always passes a third $level argument to the exception handler, even when no level is given. Anything that mocks the handler with the arguments it expects now fails:

$this->mock(ExceptionHandler::class)->expects('report')->with($exception, []);

report($exception); // No matching handler found for report($exception, [], NULL)

This is why the test suite on master has been failing since that PR, in ThrottlesExceptionsTest, ThrottlesExceptionsWithRedisTest, ValidationNotPwnedVerifierTest and ImplicitRouteBindingTest. Applications with similar expectations in their own tests would run into the same thing after upgrading.

This only passes the level when one is given, so report($e) and report($e, $context) call the handler exactly as before, while report($e, $context, LogLevel::WARNING) still forwards the level. report_if() and report_unless() go through report(), so they're covered too.

@taylorotwell
taylorotwell merged commit 4010d34 into laravel:master Sep 27, 2026
54 checks passed
binaryfire added a commit to hypervel/components-backup that referenced this pull request Oct 1, 2026
The report() helper always passed its level to the exception handler, even when none was given. Handler mocks that expect the exception and context alone no longer matched report($e) or report($e, $context). The helper now passes the level only when one is given. report_if() and report_unless() go through report(), so they behave the same way.

The handler expectations that had been changed to expect a trailing null level go back to the upstream two-argument form.

Validation: the upstream helper test is ported. The changed test files and the full parallel suite pass.

Upstream:
laravel/framework#61750

Source: laravel/framework at 588c1c948c36443a6110c44a07bb58c463e98d27.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants