Skip to content

[Security] login_check route throws exception on php 5.4.4: Parent session handler is not open #13269

Closed
@derrabus

Description

@derrabus

I tried to upgrade my client's Symfony application from 2.5.8 to the lastest 2.6-dev snapshot (12d8261). Unfortunately, the upgrade broke their login process completely, which worked fine with 2.6.1 and below.

I could reproduce the problem by creating a new Symfony Standard application and implementing a login form as described in the cookbook. If I enter correct credentials in the form here, I get the following exception on the login_check route.

[1] Symfony\Component\Debug\Exception\ContextErrorException: Warning: SessionHandler::write(): Parent session handler is not open
    at n/a
        in /home/develop/projects/session-test/app/cache/dev/classes.php line 4606

    at Symfony\Component\Debug\ErrorHandler->handleError('2', 'SessionHandler::write(): Parent session handler is not open', '/home/develop/projects/session-test/app/cache/dev/classes.php', '4606', array('sessionId' => 'vq1u2n2d008k0mbmc2hi0j0v55', 'data' => '_sf2_attributes|a:1:{s:17:"_security_default";s:853:"C:74:"Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken":765:{a:3:{i:0;N;i:1;s:7:"default";i:2;s:722:"a:4:{i:0;O:41:"Symfony\Component\Security\Core\User\User":7:{s:51:"Symfony\Component\Security\Core\User\Userusername";s:4:"demo";s:51:"Symfony\Component\Security\Core\User\Userpassword";s:4:"demo";s:50:"Symfony\Component\Security\Core\User\Userenabled";b:1;s:60:"Symfony\Component\Security\Core\User\UseraccountNonExpired";b:1;s:64:"Symfony\Component\Security\Core\User\UsercredentialsNonExpired";b:1;s:59:"Symfony\Component\Security\Core\User\UseraccountNonLocked";b:1;s:48:"Symfony\Component\Security\Core\User\Userroles";a:1:{i:0;s:9:"ROLE_USER";}}i:1;b:1;i:2;a:1:{i:0;O:41:"Symfony\Component\Security\Core\Role\Role":1:{s:47:"Symfony\Component\Security\Core\Role\Rolerole";s:9:"ROLE_USER";}}i:3;a:0:{}}";}}";}_sf2_flashes|a:0:{}_sf2_meta|a:3:{s:1:"u";i:1420472792;s:1:"c";i:1420472792;s:1:"l";s:1:"0";}'))
        in  line 

    at SessionHandler->write('vq1u2n2d008k0mbmc2hi0j0v55', '_sf2_attributes|a:1:{s:17:"_security_default";s:853:"C:74:"Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken":765:{a:3:{i:0;N;i:1;s:7:"default";i:2;s:722:"a:4:{i:0;O:41:"Symfony\Component\Security\Core\User\User":7:{s:51:"Symfony\Component\Security\Core\User\Userusername";s:4:"demo";s:51:"Symfony\Component\Security\Core\User\Userpassword";s:4:"demo";s:50:"Symfony\Component\Security\Core\User\Userenabled";b:1;s:60:"Symfony\Component\Security\Core\User\UseraccountNonExpired";b:1;s:64:"Symfony\Component\Security\Core\User\UsercredentialsNonExpired";b:1;s:59:"Symfony\Component\Security\Core\User\UseraccountNonLocked";b:1;s:48:"Symfony\Component\Security\Core\User\Userroles";a:1:{i:0;s:9:"ROLE_USER";}}i:1;b:1;i:2;a:1:{i:0;O:41:"Symfony\Component\Security\Core\Role\Role":1:{s:47:"Symfony\Component\Security\Core\Role\Rolerole";s:9:"ROLE_USER";}}i:3;a:0:{}}";}}";}_sf2_flashes|a:0:{}_sf2_meta|a:3:{s:1:"u";i:1420472792;s:1:"c";i:1420472792;s:1:"l";s:1:"0";}')
        in /home/develop/projects/session-test/app/cache/dev/classes.php line 4606

    at Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy->write('vq1u2n2d008k0mbmc2hi0j0v55', '_sf2_attributes|a:1:{s:17:"_security_default";s:853:"C:74:"Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken":765:{a:3:{i:0;N;i:1;s:7:"default";i:2;s:722:"a:4:{i:0;O:41:"Symfony\Component\Security\Core\User\User":7:{s:51:"Symfony\Component\Security\Core\User\Userusername";s:4:"demo";s:51:"Symfony\Component\Security\Core\User\Userpassword";s:4:"demo";s:50:"Symfony\Component\Security\Core\User\Userenabled";b:1;s:60:"Symfony\Component\Security\Core\User\UseraccountNonExpired";b:1;s:64:"Symfony\Component\Security\Core\User\UsercredentialsNonExpired";b:1;s:59:"Symfony\Component\Security\Core\User\UseraccountNonLocked";b:1;s:48:"Symfony\Component\Security\Core\User\Userroles";a:1:{i:0;s:9:"ROLE_USER";}}i:1;b:1;i:2;a:1:{i:0;O:41:"Symfony\Component\Security\Core\Role\Role":1:{s:47:"Symfony\Component\Security\Core\Role\Rolerole";s:9:"ROLE_USER";}}i:3;a:0:{}}";}}";}_sf2_flashes|a:0:{}_sf2_meta|a:3:{s:1:"u";i:1420472792;s:1:"c";i:1420472792;s:1:"l";s:1:"0";}')
        in  line 

    at session_write_close()
        in /home/develop/projects/session-test/app/cache/dev/classes.php line 4386

    at Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->save()
        in /home/develop/projects/session-test/app/cache/dev/classes.php line 4214

    at Symfony\Component\HttpFoundation\Session\Session->save()
        in /home/develop/projects/session-test/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/SaveSessionListener.php line 55

    at Symfony\Component\HttpKernel\EventListener\SaveSessionListener->onKernelResponse(object(FilterResponseEvent), 'kernel.response', object(ContainerAwareEventDispatcher))
        in  line 

    at call_user_func(array(object(SaveSessionListener), 'onKernelResponse'), object(FilterResponseEvent), 'kernel.response', object(ContainerAwareEventDispatcher))
        in /home/develop/projects/session-test/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php line 59

    at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(FilterResponseEvent), 'kernel.response', object(ContainerAwareEventDispatcher))
        in  line 

    at call_user_func(object(WrappedListener), object(FilterResponseEvent), 'kernel.response', object(ContainerAwareEventDispatcher))
        in /home/develop/projects/session-test/app/cache/dev/classes.php line 3876

    at Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.response', object(FilterResponseEvent))
        in /home/develop/projects/session-test/app/cache/dev/classes.php line 3809

    at Symfony\Component\EventDispatcher\EventDispatcher->dispatch('kernel.response', object(FilterResponseEvent))
        in /home/develop/projects/session-test/app/cache/dev/classes.php line 3970

    at Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.response', object(FilterResponseEvent))
        in /home/develop/projects/session-test/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php line 112

    at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch('kernel.response', object(FilterResponseEvent))
        in /home/develop/projects/session-test/app/bootstrap.php.cache line 3040

    at Symfony\Component\HttpKernel\HttpKernel->filterResponse(object(RedirectResponse), object(Request), '1')
        in /home/develop/projects/session-test/app/bootstrap.php.cache line 3011

    at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
        in /home/develop/projects/session-test/app/bootstrap.php.cache line 2982

    at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
        in /home/develop/projects/session-test/app/bootstrap.php.cache line 3131

    at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
        in /home/develop/projects/session-test/app/bootstrap.php.cache line 2376

    at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
        in /home/develop/projects/session-test/web/app_dev.php line 18

This problem only appears on our old virtual machine running php 5.4.4. On my dev machine running Ubuntu 14.10 with the bundled php 5.5.12, everything works as expected. So, this issue is probably related to that old php version. Maybe, we're facing a similar issue here as in #5868 (just guessing)?

My client is aware, that this php version is fairly old, but the application has several hundred installations and most of them under that old php version, so the migration to a more recent php release will take some time. Untill then, I would need a fix or a workaround.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions