Skip to content
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

Symfony 4.4 compatibility: use Either ErrorListener or ExceptionListener #2031

Closed
bendavies opened this issue Nov 22, 2019 · 13 comments · Fixed by #2036
Closed

Symfony 4.4 compatibility: use Either ErrorListener or ExceptionListener #2031

bendavies opened this issue Nov 22, 2019 · 13 comments · Fixed by #2036

Comments

@bendavies
Copy link
Contributor

This bundle currently has integration with with the symfony ExceptionListener here:

https://github.com/FriendsOfSymfony/FOSRestBundle/blob/7705fa0af878f28d56a182dea4f18c1e0ab9cbbb/EventListener/ExceptionListener.php

In symfony 4.4 this class is deprecated in favor of ErrorListener.

A Compiler Pass is used to use either one or the other.

This bundle needs support for both eventualities/listeners.

@maxhelias
Copy link

Should be fixed by #2025

@XWB
Copy link
Member

XWB commented Nov 26, 2019

#2025

@XWB XWB closed this as completed Nov 26, 2019
@bendavies
Copy link
Contributor Author

That PR does not resolve the issue. please reopen.

@xabbuh
Copy link
Member

xabbuh commented Nov 29, 2019

Can you provide some more information on what happens?

@xabbuh xabbuh reopened this Nov 29, 2019
@bendavies
Copy link
Contributor Author

bendavies commented Nov 29, 2019

This is converting the Exception to a FlattenedException, because the parameter here has no type.

Which results in a type error here:
TypeError: Argument 1 passed to FOS\RestBundle\Controller\ExceptionController::getStatusCode() must be an instance of Exception, instance of Symfony\Component\ErrorHandler\Exception\FlattenException given

Adding a type to $exception would fix it.

But like i said in OP,

This bundle is uses the deprecated ExceptionListener

In symfony 4.4 this class is deprecated in favor of ErrorListener.

This bundle needs to detect if the consumer is using either Symfony/Component/HttpKernel/EventListener/ExceptionListener or Symfony/Component/Console/EventListener/ErrorListener, and use the same. It will always be one or the other due to this compiler pass

@bendavies
Copy link
Contributor Author

bendavies commented Nov 29, 2019

related: since this bundle now supports symfony 5, this is totally broken since the class doesn't exist.

@yceruto
Copy link
Contributor

yceruto commented Nov 29, 2019

Yes, I can confirm that #2025 does not work in 5.0 and triggers another deprecation on 4.4. The ExceptionListener was deprecated while PR was alive.

I will try to rework it this weekend.

@yceruto
Copy link
Contributor

yceruto commented Nov 29, 2019

See #2036

@seddighi78
Copy link

how to fix this problem in Symfony 4.4?

@yceruto
Copy link
Contributor

yceruto commented Dec 30, 2019

#2036 already fix this problem on 4.4, but it's not merged yet.

@emimarz
Copy link

emimarz commented Jan 18, 2020

when going to merge it? because I have the same error

@emimarz
Copy link

emimarz commented Jan 18, 2020

are there a work around for this? meanwhile

@The-Don-Himself
Copy link

are there a work around for this? meanwhile

@emimarz this hack seems to solve it for me and a few others on Symfony 4.4

#2036 (comment)

@XWB XWB closed this as completed in #2036 Jan 19, 2020
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 a pull request may close this issue.

8 participants