dt4233 2011-10-20 23:29
浏览 31
已采纳

无法将项目升级到CakePHP-2.0

The project was developed with CakePHP-1.3

Now I'm trying to upgrade to CakePHP-2.0

I have renamed all controllers and mode with the CakePHP-2.0 conventions.

Now if I reloads the page I got error like this:

Indirect modification of overloaded property PostsController::$Auth has no effect [APP/Controller/PostsController.php, line 11]

The code:

PostsController:

$this->Auth->allowedActions =
        array('index','view','archive','listarchive','viewfromcategory','tags','aboutme','contact','polls');

AppController:

class AppController extends Controller {
    var $components = array('Acl', 'Session', 'Auth','RequestHandler');
    //var $helpers = array('Html', 'Form','Js','Session','Cache');
    var $helpers = array('Html', 'Form','Js','Session');

    function beforeFilter() {
        //Configure AuthComponent           
        $this->Auth->actionPath = 'controllers/';

        $this->Auth->allowedActions = array('display');

        //$this->Auth->authorize = 'actions';
        $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
        $this->Auth->logoutRedirect = array('controller' => 'posts', 'action' => 'index');
        $this->Auth->loginRedirect = array('controller' => 'posts', 'action' => 'index');
    }

How can I fix this problem?

  • 写回答

2条回答 默认 最新

  • dongqie4233 2011-10-21 07:01
    关注

    As mentioned in the Cake 2.0 migration guide:

    AuthComponent

    The AuthComponent was entirely re-factored for 2.0, this was done to help reduce developer confusion and frustration. In addition, AuthComponent was made more flexible and extensible. You can find out more in the Authentication guide.

    You are getting that error because of the changes to the cakephp core, so you should adjust your code according to the new guides.

    I have encountered the same issue when modifying the data array inside the controller:

    $this->data['foo'] = 'bar';
    

    and had to switch this to use the new CakeRequest object:

    $this->request->data['foo'] = 'bar';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64
  • ¥15 iOS 自定义输入法-第三方输入法
  • ¥15 很想要一个很好的答案或提示
  • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作
  • ¥15 idea右下角设置编码是灰色的