After upgrading from Symfony 2.3 to 2.4, the following exception is being thrown:
An exception has been thrown during the rendering of a template ("Rendering a fragment can only be done when handling a Request.") in PageBundle::base.html.twig at line 34.
The code is trying to render a controller:
{% if not app.user %}
<div id="login" class="fourcol last">
{{ render(controller("SecurityBundle:Front/Security:login")) }}
</div>
{% endif %}
The exception is being thrown by fragmentHandler because $request is null:
public function render($uri, $renderer = 'inline', array $options = array())
{
if (!isset($options['ignore_errors'])) {
$options['ignore_errors'] = !$this->debug;
}
if (!isset($this->renderers[$renderer])) {
throw new \InvalidArgumentException(sprintf('The "%s" renderer does not exist.', $renderer));
}
if (!$request = $this->getRequest()) {
throw new \LogicException('Rendering a fragment can only be done when handling a Request.');
}
var_dump($request); die();
return $this->deliver($this->renderers[$renderer]->render($uri, $request, $options));
}
This is also happening on other twig render function calls.
List of Symfony component versions from composer:
symfony/assetic-bundle v2.3.0
symfony/icu v1.2.0
symfony/monolog-bundle v2.3.0
symfony/swiftmailer-bundle v2.3.4
symfony/symfony v2.4.0
Any help would be greatly appreciated