Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Yii accessRules表达式不工作_Php_Yii_Rbac - Fatal编程技术网

Php Yii accessRules表达式不工作

Php Yii accessRules表达式不工作,php,yii,rbac,Php,Yii,Rbac,在我的控制器中,我有 /** * @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

在我的控制器中,我有

    /**
 * @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('*'),
        ),
    );
}
但由于某些原因,deleteComment上的表达式总是给我一个403错误(未授权)。尽管我已经测试过这个表达,并得到了真实的答案。即使将“表达式”=>“返回true;”不起作用(我完全糊涂了……有什么想法吗?
谢谢,Brad(:

在表达式的开头有一个额外的
返回值。是的,因此有两个结果会导致语法错误。删除你的,你就可以开始了