dongya2578 2013-07-27 19:31
浏览 50
已采纳

当注销链接命中时,FOS UserBundle服务器错误

I am new to the FriendsOfSymfony UserBundle and everything has been going well until I try to have a user logout. The login works perfectly and I am using the basic configuration that I have seen on many sites. I only have 2 users that need to login. The problem occurs when the user clicks on the logout URL. In this case /logout. I receve a generic server error in the browser and the error_log shows "Premature end of script headers: app_dev.php". If I hit refresh on the error page it goes back to my home page and I am logged out successfully.

Here is my firewall section in security.yml:

firewalls:
    main:
        pattern: ^/
        form_login:
            provider: fos_userbundle
            check_path: fos_user_security_check
            csrf_provider: form.csrf_provider
        logout: true
        anonymous: true

Here is the access_control section of security.yml:

access_control:
    - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel:https }
    - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/logout, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/admin/, role: ROLE_ADMIN }

Here is the fos_user section in config.yml

fos_user:
    db_driver: orm 
    firewall_name: main
    user_class: Wielding\BassBundle\Entity\User

I am generating the logout url in my twig form with:

<a href="{{ path('fos_user_security_logout') }}">logout</a>

If I am not logged into the site and I go manually to the logout url I get redirected back to the default index page without any error. If I am logged in and manually type in the logout url I get the server error. I have tried so many variations of config changes I can't even list them here. They all failed.

I even tried to write my own logout by invalidating the session in the controller and that generates the same error.

My only clue so far is an entry in dev.log:

[2013-07-27 14:51:26] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\ContextErrorException: "Warning: SessionHandler::write(): Parent session handler is not open in /home/dev2/app/cache/dev/classes.php line 407" at /home/dev2/app/cache/dev/classes.php line 407 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\ContextErrorException: Warning: SessionHandler::write(): Parent session handler is not open in /home/dev2/app/cache/dev/classes.php line 407 at /home/dev2/app/cache/dev/classes.php:407)"} []

Searching on this initially indicated that this was not something to worry about but I am out of other ideas. This is my final task in getting security working and its freaking me out.

I will gladly provide any other information needed to help solve this really annoying problem. Thanks in advance for any assistance.

  • 写回答

1条回答 默认 最新

  • duanbishai5271 2013-07-28 09:09
    关注

    It's error of PHP. You need to upgrade php to minium 5.4.11.

    Reference:

    https://github.com/symfony/symfony/issues/5868

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 我这模型写的不对吗?为什么lingo解出来的下面影子价格这一溜少一个变量
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波