Open Kingyo opened 7 years ago
HI, I've got same issue, after quick researching and debugging , i found what kind of problem is causing this error .
file - vendor/symfony/web-profiler-bundle/Resources/views/Collector/request.html.twig
line (271)- {%- set link = controller.file|file_link(controller.line) %}
and hence filter function getFileLink
file - vendor/symfony/twig-bridge/Extension/CodeExtension.php
line (196) - strtr($this->fileLinkFormat, array('%f' => $file, '%l' => $line));
cached call
$context["link"] = $this->env->getExtension('Symfony\Bridge\Twig\Extension\CodeExtension')
->getFileLink($this->getAttribute(($context["controller"] ?? $this->getContext($context, "controller")), "file", array()), $this->getAttribute(($context["controller"] ?? $this->getContext($context, "controller")), "line", array()));
$this->fileLinkFormat here is object Symfony\Component\HttpKernel\Debug\FileLinkFormatter and of course strtr doesnt understand it.
I debugged same code with symfony 2.8
$this->fileLinkFormat was null, function returned false and everything was ok.
But if call this function separately outside block {% macro set_handler.....
{{'real/path'|file_link(12) }}
You will not get any errors.
You can solve temporary this problem by comment this piece of code
file_link(controller.line) - in request.html.twig
or
//return strtr($this->fileLinkFormat, array('%f' => $file, '%l' => $line));
return $this->fileLinkFormat->format($file, $line);
in CodeExtension.php
same problem
+1
Same issue here, seems like 3.2 for twig-bridge has changed the way this is handled and fixes the issue.
Changed in composer.json to
"symfony/twig-bridge": "~3.2",
All works fine. Someone should create a PR...
Hi,
I've downloaded the skeleton and when I go on the index, I have this error:
[2016-12-03 18:16:20] app.CRITICAL: Twig_Error_Runtime: An exception has been thrown during the rendering of a template ("Warning: strtr() expects parameter 1 to be string, object given") in "@WebProfiler/Collector/request.html.twig" at line 271. (uncaught exception) at C:\wamp\www\sv\vendor\twig\twig\lib\Twig\Template.php line 222 {"exception":"[object] (Twig_Error_Runtime(code: 0): An exception has been thrown during the rendering of a template (\"Warning: strtr() expects parameter 1 to be string, object given\") in \"@WebProfiler/Collector/request.html.twig\" at line 271. at C:\\wamp\\www\\sv\\vendor\\twig\\twig\\lib\\Twig\\Template.php:222, Symfony\\Component\\Debug\\Exception\\ContextErrorException(code: 0): Warning: strtr() expects parameter 1 to be string, object given at C:\\wamp\\www\\sv\\vendor\\symfony\\twig-bridge\\Extension\\CodeExtension.php:197)"} []
I am on Windows 10, php 7.x Do you have any idea how to fix it please?
Thanks.