CakePHP错误:对非对象调用成员函数parseAccept()
我刚刚从CakePHP错误:对非对象调用成员函数parseAccept(),php,cakephp,cakephp-1.3,Php,Cakephp,Cakephp 1.3,我刚刚从cakephp1.3升级到cakephp2.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 我没有在控制器中的任何地方调用函数parseAccept(),因此不明白为什么会出现此错误。来自《蛋
cakephp1.3
升级到cakephp2.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
我没有在控制器中的任何地方调用函数parseAccept()
,因此不明白为什么会出现此错误。来自《蛋糕手册》
控制器的构造函数现在接受两个参数。结块,和
结块反应物体。这些对象用于填充多个对象
已弃用的属性,将在内部设置为$request和$response
控制器
修复方法: 更改构造函数签名 发件人:
function __construct()
{
parent::__construct();
}
// 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);
}
至:
function __construct()
{
parent::__construct();
}
// 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);
}
这应该可以解决您的错误:对非对象调用成员函数parseAccept()
有关此问题的官方Cake 2.x
文档可在此处找到:
如果您刚刚从1.x
升级到2.x
,我强烈建议您阅读cakePHP
提供的详细迁移指南
迁移指南
来自蛋糕手册
控制器的构造函数现在接受两个参数。结块,和
结块反应物体。这些对象用于填充多个对象
已弃用的属性,将在内部设置为$request和$response
控制器
修复方法:
更改构造函数签名
发件人:
function __construct()
{
parent::__construct();
}
// 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);
}
至:
function __construct()
{
parent::__construct();
}
// 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);
}
这应该可以解决您的错误:对非对象调用成员函数parseAccept()
有关此问题的官方Cake 2.x
文档可在此处找到:
如果您刚刚从1.x
升级到2.x
,我强烈建议您阅读cakePHP
提供的详细迁移指南
迁移指南
在Cakephp 2.x中,AppController的_construct()有两个对象。结块和蛋糕反应。
您需要传递给父构造函数
public function __construct($request = null, $response = null) {
parent::__construct($request, $response);
//you code here
}
在Cakephp 2.x中,AppController的_construct()有两个对象。结块和蛋糕反应。
您需要传递给父构造函数
public function __construct($request = null, $response = null) {
parent::__construct($request, $response);
//you code here
}