slimphp / slimphp/Slim

Logger not forwarded to own ErrorHandlingMiddleware

Open
#2,943 20 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Slim 5
Dominant language
PHP
Stars
12.3k
Forks
2k
Avg merge
3d 2h
Merged PRs (30d)
6

Description

As written in documentaton the customErrorHandler should receive the logger of the ErrorMiddleware as 6th parameter.
But unfortunately the customErrorHandler always receives null. This can be reproduced by just copying the code from the documentation.
Did some research and it seems the logger is not correctly submitted to the handler in the line below.

https://github.com/slimphp/Slim/blob/5613cbb521081ed676d5d7eb3e44f2b80a818c24/Slim/Middleware/ErrorMiddleware.php#L127

I've added $this->logger locally on my server and now my customErrorHandler gets the logger as intended.
I'm not aware of side effects this could have so created an issue here and no pull request.

Best.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Slim/Middleware/ErrorMiddleware.php at the linked line and compare the handler arguments with the error-handling documentation example. Reproduce the documented customErrorHandler case and confirm that the handler receives the ErrorMiddleware logger instead of null.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.