Fosrestbundle: Not working Exception Handling in ExceptionController with PHP 7

Created on 26 Feb 2020  路  7Comments  路  Source: FriendsOfSymfony/FOSRestBundle

Please fix the bug:
php.CRITICAL: Uncaught Error: Argument 3 passed to FOS\RestBundle\Controller\ExceptionController::getTemplateData() must be an instance of Exception, instance of TypeError given, called in /var/www/html/vendor/friendsofsymfony/rest-bundle/Controller/ExceptionController.php on line 74
It麓s already reported in https://github.com/FriendsOfSymfony/FOSRestBundle/issues/2092 after it was closed.

Bug

All 7 comments

I'm getting the same error.
Previously this error was being launched in the getStatusCode() method. Now it's the getTemplateData().

Line 69: vendor/friendsofsymfony/rest-bundle/Controller/ExceptionController.php

if ($exception instanceof \Exception) { $code = $this->getStatusCode($exception); } else { $code = $this->getStatusCodeFromThrowable($exception); }

The latest release 2.7.1 has made some improvements to check the exception instance in the showAction() method but apparently it has forgot to handle the getTemplateData() method requiring an \Exception Type as a 3rd parameter
(public function getTemplateData($currentContent, $code, \Exception $exception, DebugLoggerInterface $logger = null)

For the moment, and as temporary workaround for this issue, I'm using a custom exception controller similar to the original fos_rest controller while avoiding this conflict !

And please don麓t forget to fix the method call on function "createView".

Pr #2096 is now ok, i wait feedback from fos team :)

@MissbachMichael @faresk93 Can you both confirm that the current 2.7 branch after #2096 being merged fixes your issue? If yes, I will tag a new bugfix release later today.

I believe this hasn't solved the problem yet ! @xabbuh
I got another exception related to jms-serializer

image

The problem is now in handling the created $view argument on line 82.
I believe I know how to solve this. I'll look into it later today!

@faresk93 Thank you for the feedback. Please ping me if I can help you or when you need some feedback.

I created I pull request fixing this issue @xabbuh

2104

Was this page helpful?
0 / 5 - 0 ratings