Hi,
Error seems appear with SensioFrameworkExtraBundle v3.0.13, and crash all my code.
I hope someone has an idea..
Here is the Stack Trace returned by Symfony
Stack Trace
1 - in vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/View/View.php at line 218 -
public function setTemplate($template)
{
if (!(is_string($template) || $template instanceof TemplateReference)) {
throw new \InvalidArgumentException('The template should be a string or extend TemplateReference');
}
$this->template = $template;
2 - at View ->setTemplate (object(Template))
in vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/EventListener/ViewResponseListener.php at line 122 -
$template->set('format', null);
}
$view->setTemplate($template);
}
}
3 - at ViewResponseListener ->onKernelView (object(GetResponseForControllerResultEvent), 'kernel.view', object(TraceableEventDispatcher))
at call_user_func (array(object(ViewResponseListener), 'onKernelView'), object(GetResponseForControllerResultEvent), 'kernel.view', object(TraceableEventDispatcher))
in vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php at line 61 -
$e = $this->stopwatch->start($this->name, 'event_listener');
call_user_func($this->listener, $event, $eventName, $this->dispatcher ?: $dispatcher);
if ($e->isStarted()) {
$e->stop();
I just upgraded sensio/framework-extra-bundle from v3.0.11 to v3.0.13 and
FOS/RestBundle from 1.7.4 to 1.7.7 and had the same exception for Controller Action with an Template annotation.
I found that making a configuration change in config.yml got things working again for me, but I must warn that I haven't confirmed whether the change has adversely affected other things.
I changed:
fos_rest:
view:
view_response_listener: force
to:
fos_rest:
view:
view_response_listener: true
and things started working again. Hopefully that will help you. You may also want to check out #1301 which seems to mention a similar sort of problem.
I tried this because of the documentation on this page: http://symfony.com/doc/1.7/bundles/FOSRestBundle/view_response_listener.html
fos_rest:
view:
view_response_listener: force
This config allows to return data from controller action without adding @View annotation (it will force using view), instead of "view_response_listener : true" which use SensioFrameworkExtraBundle if there is no @View annotation.
http://symfony.com/doc/current/bundles/FOSRestBundle/view_response_listener.html
When view_response_listener is set to true instead of force and @View() is not used, then rendering will be delegated to SensioFrameworkExtraBundle
So, we can resolve this issue by adding @View annotation on each action.
But it means that "view_response_listener : force" doesn't work anymore.
Thanks for the report, I'll take a look at it this afternoon.
https://github.com/sensiolabs/SensioFrameworkExtraBundle/commit/82b8ad65409c99f693088ecbc09c857f01e3b3fa removed many request attributes so we can't use them anymore ...
We have to refactor the ViewResponseListener to work again.
@lsmith77 @xabbuh I think we should mark SensioFrameworkExtraBundle > 3.0.13 as not supported in 1.7/1.8 and fix its support in 2.0 to not have too much work to do.
@Ener-Getick Dropping support for a patch release version looks like an ugly hack to me. Is this actually a BC break in the SensioFrameworkExtraBundle or did rely on implementation details?
I agree but SensioFrameworkExtraBundle introduced a big bc break in a patch...
@xabbuh just take a look at https://github.com/sensiolabs/SensioFrameworkExtraBundle/commit/82b8ad65409c99f693088ecbc09c857f01e3b3fa and all the request attributes no longer available.
I was running into this as well and noticed my issues went away with the current "dev-master". How close is a v2.0 release cut? :)
@blamonet many parts of the ViewResponseListener are broken with SensioFrameworkExtraBundle 3.0.13 so I advise to use the version 3.0.12 until we fix this issue.
Otherwise, you may have a weird behavior without knowing it.
The change that probably causes this is here. If you can point me to the location in this bundle where it breaks, I can try to submit a patch.
@iltar I opened https://github.com/FriendsOfSymfony/FOSRestBundle/issues/1355
Looks good as far as I can see :+1:
@Ener-Getick thank you for the clarification. Things are now working out much better! :+1:
@xabbuh the code of the bundle clearly relied on the internal implementation details IMO
@stof @xabbuh @lsmith77 can you take a look at https://github.com/FriendsOfSymfony/FOSRestBundle/pull/1355 and #1362 please?
Most helpful comment
I just upgraded sensio/framework-extra-bundle from v3.0.11 to v3.0.13 and
FOS/RestBundle from 1.7.4 to 1.7.7 and had the same exception for Controller Action with an Template annotation.
I found that making a configuration change in config.yml got things working again for me, but I must warn that I haven't confirmed whether the change has adversely affected other things.
I changed:
to:
and things started working again. Hopefully that will help you. You may also want to check out #1301 which seems to mention a similar sort of problem.
I tried this because of the documentation on this page: http://symfony.com/doc/1.7/bundles/FOSRestBundle/view_response_listener.html