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
fix: Set twig.exception_listener as service parent #5059
Conversation
Not a huge fan of fixing 2.7 for this as we changed this in 3.0. Can't we fix the twig version on lowest instead ? |
The nearest lower compliant Twig version would be 4.3, therefore it means that ApiPlatform 2.7 could not run on Symfony 4.4, which is a LTS largely used. |
For record, a workaround can be to redifine the //config/services.yml
services:
[...]
api_platform.error_listener:
class: ApiPlatform\Symfony\EventListener\ErrorListener
arguments:
$controller: "@api_platform.action.exception"
$logger: "@logger"
$debug: "%kernel.debug%" |
On a web application with an api, I have a response in the
Maybe another workaround is to use an alias
|
can you fix the tests ? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Dear bot, please wait. |
Very interested in this PR! @paulandrieux Could you find it in your heart to fix the tests too? 😄 |
…listener` service
@soyuka Tests are now fixed |
perfect thanks @paulandrieux ! |
* chore: switch from deprecated “loose” email validation mode to “html5” (#5326) * chore: replace `Request::getContentType` with `Request::getContentTypeFormat` if available (#5325) * fix: Set twig.exception_listener as service parent (#5059) * fix(symfony): remove dependency on potentially inexistant `exception_listener` service * define argument keys on service redefinition * fix: avoid unneeded use of covariance to keep compatibility with PHP < 7.4 (#5327) * fix(symfony): http cache wrong metadata argument * chore: changelog 2.7.6 Co-authored-by: Mathieu <mathieu.lechat@les-tilleuls.coop> Co-authored-by: Paul Andrieux <paul@appventus.com>
On branch 2.7, the service
api_platform.error_listener
definesexception_listener
as parent. https://github.com/api-platform/core/blob/main/src/Symfony/Bundle/Resources/config/api.xml#L170Twig v4.4 deletes the definition of
exception_listener
and replaces it bytwig.exception_listener
https://github.com/symfony/twig-bundle/blob/4.4/DependencyInjection/Compiler/ExceptionListenerPass.php#L43So, when using api_platform 2.7 and twig 4.4, the following error occurs at cache clear :
This PR checks if twig is enabled, and changes the parent of
api_platform.error_listener
fromexception_listener
totwig.exception_listener
.I'm not convinced that this is the best condition, nor this is the right place to do this check, any advice ?