symfony-cmf/block-bundle

ServiceCircularReferenceException with BlockVarnishCache

gonzalovilaseca opened this issue · 17 comments

I'm trying to run Esi with CMF Block bundle, but I'm getting this exception:

ServiceCircularReferenceException: Circular reference detected for service "http_kernel", path: "http_kernel -> debug.event_dispatcher -> profiler -> sonata.block.templating.helper -> sonata.cache.manager -> cmf.block.cache.varnish -> fragment.handler -> fragment.renderer.inline".



    in /var/www/app/bootstrap.php.cache line 1951
    at Container->get('http_kernel') in /var/www/app/cache/dev/appDevDebugProjectContainer.php line 3666
    at appDevDebugProjectContainer->getFragment_Renderer_InlineService() in /var/www/app/bootstrap.php.cache line 1974
    at Container->get('fragment.renderer.inline') in /var/www/app/cache/dev/appDevDebugProjectContainer.php line 3602
    at appDevDebugProjectContainer->getFragment_HandlerService() in /var/www/app/bootstrap.php.cache line 1974
    at Container->get('fragment.handler') in /var/www/app/cache/dev/appDevDebugProjectContainer.php line 1106
    at appDevDebugProjectContainer->getCmf_Block_Cache_VarnishService() in /var/www/app/bootstrap.php.cache line 1974
    at Container->get('cmf.block.cache.varnish') in /var/www/app/cache/dev/appDevDebugProjectContainer.php line 6132
    at appDevDebugProjectContainer->getSonata_Cache_ManagerService() in /var/www/app/bootstrap.php.cache line 1974
    at Container->get('sonata.cache.manager', '2') in /var/www/app/cache/dev/appDevDebugProjectContainer.php line 14290
    at appDevDebugProjectContainer->getSonata_Block_Templating_HelperService() in /var/www/app/bootstrap.php.cache line 1974
    at Container->get('sonata.block.templating.helper') in /var/www/app/cache/dev/appDevDebugProjectContainer.php line 5414
    at appDevDebugProjectContainer->getProfilerService() in /var/www/app/bootstrap.php.cache line 1974
    at Container->get('profiler', '2') in /var/www/app/cache/dev/appDevDebugProjectContainer.php line 1680
    at appDevDebugProjectContainer->getDebug_EventDispatcherService() in /var/www/app/bootstrap.php.cache line 1974
    at Container->get('debug.event_dispatcher') in /var/www/app/cache/dev/appDevDebugProjectContainer.php line 3696
    at appDevDebugProjectContainer->getHttpKernelService() in /var/www/app/bootstrap.php.cache line 1974
    at Container->get('http_kernel') in /var/www/app/bootstrap.php.cache line 2251
    at Kernel->getHttpKernel() in /var/www/app/bootstrap.php.cache line 2247
    at Kernel->handle(object(Request)) in /var/www/web/app_dev.php line 42

cmf.block.cache.varnish needs fragment.handler.
The following call is done in a compiler pass on fragment.handler:

$instance->addRenderer($this->get('fragment.renderer.inline'));

And fragment.renderer.inline needs http_kernel, so a circular exception is raised.
Any ideas on how to solve it?

It seems that the problem comes from the profiler, sonata block bundle adds sonata.block.templating.helper to the profiler data_collector, and that is the reason for the circular reference exception.
I'm going to look further into this.

dbu commented

thanks and good luck! please tell if you find something.

its pretty busy here, did not have time to look into it myself.

Hello gonzalovilaseca,
did you manage to do something with this error?

I haven't had the time to look further, I found that if you disable the data_collector in the sonata bundle, you can temporarily fix it. I have to look further..I just don't know when I'll have the time.
Are you getting this error too?

I'm not not sure that it is exactly the same error but I also have a circular reference.
it append when i Upgrade sf2.1 to 2.3 solving all dependancies about sonata.

as the path is almost the same I was hopping that you solved it :-)

@gonzalovilaseca I manage to isolate from where the problem was originate.

The BlockBundle add into the profiler a custom dataCollector to show the blocks list in the profiler.
If I disable this service, declared in the vendor sonataBlockBundle it works like a charm.

I'm looking deeper to see if I have in my app a service that would require a service required by the vendor service.

'sonata.block.data_collector' declared in: vendor/sonata-project/block-bundle/DependencyInjection/SonataBlockExtension.php

dbu commented

maybe the service that dataCollector service could be made lazy to solve the circularity issue?

Thanks @dbu, I tried to set into the vendor definition to lazy but it didn't solve the circular reference.

dbu commented

does the problem also occur with only sonata cache and sonata block, without cmf block? or does sonata do some clever trick with their service that we could mimick?

Actually I have no idea, I just get a full web app with a lot of bundles configured.
the app is to much integrate with CMF to be able to deactivate it. (mainly the order for routers between sf and sonata)

dbu commented

sorry, i also don't know enough why this starts to happen or what to do without digging deep into it - for which i unfortunately have no time at this point.

can you deactivate profiling in the sonata block bundle to break the circle?

dbu commented

@rmsint i think you originally added this. can you help us where this comes from? do you have any idea how to break the circle or where to look for the cause of that circle?

Thanks for your reply,
I completely understand your lack of time, I already disable it in my dev vendors,
Until a possible answer or finding of the problem, do you think it could be possible to add a parameter to disable this dataCollector ?

dbu commented

that could make sense yes. but would need to be done in the sonata bundle, not here, right? you would have to ask rande for sonata, or just propose a PR.

Oo That's right, I thought I was on it.
i'll try to do the PR as soon as I can Thanks for your answers.

ping

I haven't looked further, but this configuration disables de profiler listener:

sonata_block:
    profiler:
        #If the profiler is enabled a circular reference exception is launched
        enabled:        false
        container_types: ~