1
votes

Currently, we install our web application in Symfony2 and we find a blocking problem.

  • linux Debian Wheezy
  • PHP 5.4.4
  • Symfony version 2.1.10-DEV - app/dev/debug

The fatal error to the exception :

vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php throw new \LogicException('Cannot change the ID of an active session');

Stack Trace :

in kernel.root_dir/cache/dev/classes.php at line 484 -+ public function setId($id) { if ($this->isActive()) { throw new \LogicException('Cannot change the ID of an active session'); } session_id($id); at AbstractProxy ->setId ('09g5hbsvg1apk8d32k52l19rr5') in kernel.root_dir/cache/dev/classes.php at line 208 -+ at NativeSessionStorage ->setId ('09g5hbsvg1apk8d32k52l19rr5') in kernel.root_dir/cache/dev/classes.php at line 780 -+ at Session ->setId ('09g5hbsvg1apk8d32k52l19rr5') in /home/wwwmain/www_v5/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/EventListener/TestSessionListener.php at line 54 -+ at TestSessionListener ->onKernelRequest (object(GetResponseEvent)) at call_user_func (array(object(TestSessionListener), 'onKernelRequest'), object(GetResponseEvent)) in /home/wwwmain/www_v5/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/ContainerAwareTraceableEventDispatcher.php at line 139 -+ at ContainerAwareTraceableEventDispatcher ->doDispatch (array(array(object(ProfilerListener), 'onKernelRequest'), array(object(TestSessionListener), 'onKernelRequest'), array(object(SessionListener), 'onKernelRequest'), array(object(RouterListener), 'onKernelRequest'), array(object(LocaleListener), 'onKernelRequest'), array(object(Firewall), 'onKernelRequest'), array(object(RequestListener), 'onKernelRequest'), array(object(TwigExtension2), 'onKernelRequest'), array(object(RequestListener), 'onKernelRequest')), 'kernel.request', object(GetResponseEvent)) in kernel.root_dir/cache/dev/classes.php at line 4781 -+ at EventDispatcher ->dispatch ('kernel.request', object(GetResponseEvent)) in kernel.root_dir/cache/dev/classes.php at line 4999 -+ at ContainerAwareEventDispatcher ->dispatch ('kernel.request', object(GetResponseEvent)) in /home/wwwmain/www_v5/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/ContainerAwareTraceableEventDispatcher.php at line 78 -+ at ContainerAwareTraceableEventDispatcher ->dispatch ('kernel.request', object(GetResponseEvent)) in kernel.root_dir/bootstrap.php.cache at line 1412 -+ at HttpKernel ->handleRaw (object(Request), '1') in kernel.root_dir/bootstrap.php.cache at line 1392 -+ at HttpKernel ->handle (object(Request), '1', true) in kernel.root_dir/bootstrap.php.cache at line 1568 -+ at HttpKernel ->handle (object(Request), '1', true) in kernel.root_dir/bootstrap.php.cache at line 619 -+ at Kernel ->handle (object(Request)) in /home/wwwmain/www_v5/web/app_dev.php at line 25 -+

Logs :

DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\TestSessionListener::onKernelRequest". DEBUG - Notified event "kernel.exception" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelException". DEBUG - Notified event "kernel.exception" to listener "Symfony\Component\HttpKernel\EventListener\ExceptionListener::onKernelException". CRITICAL - LogicException: Cannot change the ID of an active session (uncaught exception) at /home/wwwmain/www_v5/app/cache/dev/classes.php line 484 DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\TestSessionListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\SessionListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "Symfony\Component\Security\Http\Firewall::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "Eyrolles\CompteBundle\Service\RequestListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "Eyrolles\EcommerceBundle\Twig\Extension\TwigExtension2::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "Symfony\Bundle\AsseticBundle\EventListener\RequestListener::onKernelRequest". DEBUG - Notified event "kernel.controller" to listener "Symfony\Bundle\FrameworkBundle\DataCollector\RouterDataCollector::onKernelController". DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ControllerListener::onKernelController". DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ParamConverterListener::onKernelController". DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\TemplateListener::onKernelController". DEBUG - Notified event "kernel.controller" to listener "Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::onKernelController".

Any ideas, thoughts?

1
Have you tried with a stable version of Symfony?Maerlyn
Would be also nice to know what you're actually doing (code example please!).Jakub Zalas

1 Answers

0
votes

Looks like you are running phpunit tests? If so, then calss TestSessionListener calls Session::setId() if it finds Cookie with session name.

I'm, also encounter this problem. Looks like the only way is to extends this class and override "test.session.listener.class" parameter.