调用非对象上的成员函数parseAccept

调用非对象上的成员函数parseAccept

本文介绍了CakePHP错误:调用非对象上的成员函数parseAccept()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚从

官方 Cake 2.x docs 可以在这里找到:





如果您刚刚从 1.x 升级到 2.x ,我强烈建议您阅读 cakePHP 提供的详细迁移指南。



迁移指南










I have just upgraded from CakePHP 1.3 to cakePHP 2.4.5.

I am getting the following error:

Fatal Error
Error: Call to a member function parseAccept() on a non-object
File: /myapp/lib/Cake/Controller/Component/RequestHandlerComponent.php
Line: 157

I'm not calling the function parseAccept() anywhere within my controller, and so don't understand why I am getting this error.

解决方案

From the Cake Manual


The Fix:

Change your constructor signature..

From:

function __construct()
{
    parent::__construct();
}

To:

// 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);
}

This should resolve your Error: Call to a member function parseAccept() on a non-object.

The official Cake 2.x docs for this issue can be found here:

http://book.cakephp.org/2.0/en/appendices/2-0-migration-guide.html#controller

If you have just upgraded from 1.x to 2.x, I would highly recommend you read through the detailed migration guides provided by cakePHP.

Migration Guides

2.0 Migration Guide
2.1 Migration Guide
2.2 Migration Guide
2.3 Migration Guide
2.4 Migration Guide

这篇关于CakePHP错误:调用非对象上的成员函数parseAccept()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 14:16