该项目是用CakePHP-1.3开发的
现在我正在尝试升级到CakePHP-2.0
我使用CakePHP-2.0约定重命名了所有控制器和模式。
现在,如果我重新加载页面,我会得到这样的错误:
Indirect modification of overloaded property PostsController::$Auth has no effect [APP/Controller/PostsController.php, line 11]代码:
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');
}我如何解决这个问题?
发布于 2011-10-21 15:01:30
正如在Cake 2.0 migration guide中提到的
AuthComponent
AuthComponent在2.0中被完全重构,这是为了帮助减少开发人员的困惑和挫败感。此外,AuthComponent变得更加灵活和可扩展。您可以在Authentication指南中找到更多信息。
由于cakephp核心的更改,你会得到这个错误,所以你应该根据新的指南调整你的代码。
在修改控制器内部的数据数组时,我遇到了同样的问题:
$this->data['foo'] = 'bar';并且必须将其转换为使用新的CakeRequest对象:
$this->request->data['foo'] = 'bar';发布于 2011-10-26 00:49:48
要修复警告,可以尝试执行以下操作:
在你的"PostsController“替换中:
$this->Auth->allowedActions =
array('index','view','archive','listarchive','viewfromcategory','tags','aboutme','contact','polls');通过
$this->Auth->allow(array('index','view','archive','listarchive','viewfromcategory','tags','aboutme','contact','polls'));https://stackoverflow.com/questions/7843460
复制相似问题