Ani*_*nil 1 php cakephp cakephp-1.3
我刚刚升级CakePHP 1.3到cakePHP 2.4.5.
我收到以下错误:
Fatal Error
Error: Call to a member function parseAccept() on a non-object
File: /myapp/lib/Cake/Controller/Component/RequestHandlerComponent.php
Line: 157
Run Code Online (Sandbox Code Playgroud)
我没有parseAccept()在我的控制器中的任何地方调用该函数,所以不明白我为什么会收到此错误.
Controller的构造函数现在有两个参数.CakeRequest和CakeResponse对象.这些对象用于填充多个已弃用的属性,并将在控制器内设置为$ request和$ response.
更改构造函数签名..
从:
function __construct()
{
parent::__construct();
}
Run Code Online (Sandbox Code Playgroud)
至:
// Pass through the request and response objects
// AND declare the visibility of the method
public function __construct($request = null, $response = null)
{
parent::__construct($request, $response);
}
Run Code Online (Sandbox Code Playgroud)
这应该解决你的问题Error: Call to a member function parseAccept() on a non-object.
这个问题的官方Cake 2.x文档可以在这里找到:
http://book.cakephp.org/2.0/en/appendices/2-0-migration-guide.html#controller
如果您刚刚升级1.x到2.x,我强烈建议您仔细阅读提供的详细迁移指南cakePHP.
2.0迁移指南
2.1迁移指南
2.2迁移指南
2.3迁移指南
2.4迁移指南