-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpKernel] Circular reference detected for service "templating" #6730
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
Comments
Getting this with KnpPaginator after updating to symfony 2.2
Which seems fixed here: KnpLabs/KnpPaginatorBundle#133 Not sure if it's up to the bundles to change or if it should be changed here? |
Bundles are one thing, but this breaks the usage of the templating service when used without a request (I believe this will affect console applications as well). Injecting the container should resolve this (as described in the documentation for Twig extensions). If @fabpot agrees I can work a pull request. |
@fabpot ping |
This PR was merged into the master branch. Commits ------- 94cb13d [FrameworkBundle] fixed circular reference for service templating (closes #6730, closes #6762) Discussion ---------- [FrameworkBundle] fixed circular reference for service templating (closes #6730, closes #6762) | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #6730, #6762 | License | MIT | Doc PR | n/a --------------------------------------------------------------------------- by tristanbes at 2013-01-18T14:55:39Z @fabpot Do you have an idea when you'll merge it please ?
We are still having this issue while getting templating service via a doctrine listener, web requests are fine but when we try to load fixtures we are getting the same error : [Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException] |
@joelwurtz That's weird. Have you flush your cache? If yes, can you send me your appDevDebugProjectContainer.php file from your project? |
Yes, (try the hard way rm -rf app/cache still the same issue), here my appDevDebugProjectContainer.php : https://gist.github.com/7495a23b6a62c216340e |
You can reproduce the error easily by using doctrine fixtures and try to do a $this->container->get('templating'); in a fixture file (which implements ContainerAwareInterface of course) |
Same problem with the latest version from symfony and NelmioApiDocBundle |
ok, I get it now. You have only configured Twig as a templating engine, whereas all other examples were using both PHP and Twig. I'm going to have a look at this issue. |
In the meantime, adding |
I've just submitted a PR to fix this issue (see #6850). I'm not proud of this workaround, but there is no way we can fix it easily with the way the container works. Can someone confirm that it works before I merge? |
Yup, works for me :) Thx! |
This PR was merged into the master branch. Commits ------- 65b4112 fixed a circular reference (closes #6730) Discussion ---------- fixed a circular reference (closes #6730) | Q | 7C65 A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #6730 | License | MIT | Doc PR | n/a --------------------------------------------------------------------------- by stof at 2013-01-23T13:56:19Z shoudln't this be moved to the component ? Someone using the TwigBridge, HttpKernel and the DI component outside the full stack framework (let's say Drupal maybe) would also face the circular reference issue --------------------------------------------------------------------------- by fabpot at 2013-01-23T13:58:28Z No, they won't as the problem is only if you are using the templating component. So, Silex or Drupal won't have the problem. --------------------------------------------------------------------------- by stof at 2013-01-23T14:01:03Z ah, the issue is indeed with the TwigEngine, not with the Twig_Environment service.
…yView() method can't be used and you have to use the setHTML() method directly. The reason for this change is because i was trying to use the bundle in a symfony 2.1 project and 2.1 has this bug symfony/symfony#6730. Once we get off 2.1 we can revert to the master branch.
Yesterday I started experimenting with Symfony 2.2-beta, but after running the the tests I got the following error.
Circular reference detected for service "templating", path: "templating -> debug.templating.engine.twig -> twig -> twig.extension.httpkernel -> http_content_renderer -> http_content_renderer.strategy.hinclude".
The only thing on the calling line is this $this->container->get('templating').
Its a functional test that does execute any route, so I guess thats the reason why this was not found earlier.
The problem (from what I have found) is because Twig has the twig.extension.httpkernel which relies on the http_content_renderer which in turn calls the http_content_renderer.strategy.hinclude. And http_content_renderer.strategy.hinclude uses the Templating service causing the Circular reference.
When using the Controller this will not happen because the http_content_renderer 'seems' to be executed before any rendering and preventing the Circular reference from happening.
When I disable the hinclude service (comment
<tag />
) it works.So the only fix I can think of is to pass the Container to the hinclude service and get the templating service when needed (as described in the docs).
Related to #6459
The text was updated successfully, but these errors were encountered: