-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logger not forwarded to own ErrorHandlingMiddleware #2943
Comments
Wow such an oversight on my part. I will open a PR to fix this asap. Thanks for reporting this! |
@elazar we screwed up injecting the I'm not sure how to elegantly fix this without introducing a breaking change by removing it from the constructor: If we leave it in the constructor, then what happens during the invocation? Do we replace the logger that it was originally constructed with? We need to find an order of precedence. @adriansuter thoughts? |
@elazar there's another problem here |
@l0gicgate I'm not sure there's an elegant way to address this either, honestly. The functionality as it stands is broken regardless. I'm not sure API changes would make the situation that much worse since they were originally written to avoid breaking BC anyway. The constructor parameter currently defaults to We can basically just relocate the parameter as-is to be a parameter of Technically, yes, we're changing signatures, but not in a way that should break any calling code that wasn't already indirectly broken by this feature not working. |
Let’s test this to make sure
I’m almost 100% sure that changing the signature of an interface will break any code implementing it regardless of if the additional parameter at the end is nullable or not. We should test this as well before making any further changes. |
OK, so changing the interface isn't an option. That basically leaves us with changing how the feature works, and updating the docs accordingly. We could, for example, add a check in This unfortunately excludes the use of lambdas, but I'm not sure there's another way that doesn't involve an API-breaking change. This would at least make working functionality available in some form now, and the API could be revisited in Slim 5. |
One thing to remember is that it couldn't have been implemented in the original PR since we would have broken At this point, I think it may be worth pushing any further changes to the next major version instead where we can rework how we interface with logging entirely:
In the mean time, we should document this shortcoming in the docs. I think this may just be a trade-off of not breaking anything in a minor version. |
@elazar @l0gicgate @akrabat |
@ddrv |
I do agree that separating those concerns would make more sense:
|
Relatively small changes for Slim 5 will at least make the upgrade path possible! |
I would rename title of this issue. From the first sight it says "Slim internal ErrorMiddleware is broken" which is not. Then after a few comments I understand that it's related to custom handlers only. Btw almost |
@ybelenko I guess you mean… 1 YEAR and 10 days. |
This comment has been minimized.
This comment has been minimized.
We do need to fix the docs. And yes, the issue has been open for over a year because this can't be resolved until Slim 5 without breaking things. Slim 5 isn't even in development. Managing 10+ repos, with 2 full time jobs isn't easy, all help is welcomed. |
I'm not whining that bug not fixed, it's open source software without any warranties. It's just weird that docs not updated after a year, so users still can face the same bug because of a wrong line in doc example. @l0gicgate, as opensource developer(without starred repos for now) myself, I appreciate your work. |
Thank you @ybelenko updated the docs: |
As written in documentaton the
customErrorHandler
should receive the logger of theErrorMiddleware
as 6th parameter.But unfortunately the
customErrorHandler
always receivesnull
. 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.
Slim/Slim/Middleware/ErrorMiddleware.php
Line 127 in 5613cbb
I've added
$this->logger
locally on my server and now mycustomErrorHandler
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.
The text was updated successfully, but these errors were encountered: