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 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题