duang5049 2013-09-06 20:37
浏览 96

CakePHP:无法在models.php中重新声明类AppModel

I installed CakePHP 2.4.0 and it appears to be working okay, but when the request finishes I get an internal error that AppModel has been redeclared. The stack trace does not even include any of my code, only cakePHP code. It is something to do with the testing system, which I am not even using. The bug appears in a brand new installation and has apparently been fixed a number of times over the years, and in a number of different ways, but it still happens.

Here are two different reports of this problem, along with the fixes that allegedly fixed it. https://github.com/cakephp/cakephp/pull/617

https://github.com/Phally/lazy_model/issues/5

The first solution above was already implemented in cake 2.4.0, but the bug still shows up even with that fix in place. I tried the second solution, but it did not change anything.

Does anyone know a permanent solution to this problem?

  • 写回答

1条回答 默认 最新

  • 我在西湖1 2013-12-17 22:16
    关注

    Double check your models to make sure you have the following in the top of your model that is extending AppModel.

    App::uses('AppModel', 'Model');

    This means the top of your model should look something like:

    <?php
    App::uses('AppModel', 'Model');
    class MyModel extends AppModel {
    
    评论

报告相同问题?

悬赏问题

  • ¥15 制裁名单20240508芯片厂商
  • ¥20 易康econgnition精度验证
  • ¥15 线程问题判断多次进入
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接