【问题标题】:After upgrading php version All Errors Are Now "An Internal Server Error Occurred" in cake php升级 php 版本后,所有错误现在都是 cake php 中的“发生内部服务器错误”
【发布时间】:2018-06-04 10:55:09
【问题描述】:

我正在使用 cake php 3。几天前我已经将 php 版本从 5.6 更新到 7.1.17 。现在,如果我的应用程序发生任何错误,它会显示An Internal Server Error Occurred"。我可以在我的error.log 文件中看到错误日志,像这样[Error] Call to a member function user() on boolean Request URL: /robots.txt

这是我的user() 函数的调用方式。它在 php 5.6 上运行良好..

public function beforeRender(Event $event)
{
    if($this->Auth->user()){
        $this->set('loggedIn', true);
    }
    else{
        $this->set('loggedIn',false);
    }
}

【问题讨论】:

  • 调用 robots.txt 时为什么会出现这种情况?您是否尝试设置断点并调试 beforeRender() ?

标签: cakephp-3.0


【解决方案1】:

这就是我解决问题的方法。在beforeRender 函数中添加了这一行$this->loadComponent('Auth');。我得到了这个解决方案 Fatal error: Call to a member function user() on boolean

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-07-28
    • 2016-09-08
    • 1970-01-01
    • 1970-01-01
    • 2013-07-02
    • 2013-07-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多