Yii accessRules表达式不起作用

Bra*_*eed 2 php rbac yii

在我的控制器中,我有

    /**
 * @return array action filters
 */
public function filters()
{
    return array(
        'accessControl', // perform access control for CRUD operations
    );
}

/**
 * Specifies the access control rules.
 * This method is used by the 'accessControl' filter.
 * @return array access control rules
 */
public function accessRules()
{
    return array(
        array('allow',  // allow all users to perform 'index' and 'view' actions
            'actions'=>array('index','view'),
            'users'=>array('*'),
        ),
        array('allow', // allow players to comment on games
            'actions'=>array('createComment'),
            'roles'=>array('createComment'),
        ),
  array('allow', // allow users to update and delete their own comments
    'actions'=>array('deleteComment'),
    'expression'=>'return $user->id==Game::model()->findByPk(Yii::app()->getRequest()->getQuery("id"))->author->id;',
  ),
        array('allow', // allow admin users to create, update, delete and manage games
            'actions'=>array('admin','create','update','delete','deleteComment'),
    'roles'=>array('admin'),
        ),
        array('deny',  // deny all users
            'users'=>array('*'),
        ),
    );
}
Run Code Online (Sandbox Code Playgroud)

但由于某种原因,deleteComment上的表达式总是给我403错误(未授权).即使我已经测试了那个表达并且变成了现实.甚至把'expression'=>'return true;' 不起作用.:(我完全糊涂了......任何想法?谢谢,布拉德(:

Jon*_*Jon 10

return在表达的开头你有一个额外的.Yii 已经添加了一个,因此有两个结果导致语法错误.删除你的,你会很高兴去.