Closed atiberius closed 7 years ago
It seems to be working fine for me.
The code you posted
if (!isset($roleParams)) {
$roleParams = $this->roleParams instanceof Closure ? call_user_func($this->roleParams, $this) : $this->roleParams;
}
is checking for $this->roleParams
. By default that value is public $roleParams = [];
so it's not calling any function there.
I think you left something out ... Can you post your entire public function behaviors() {
code
This is my full behaviors()
function:
public function behaviors() {
return [
'access' => [
'class' => AccessControl::className(),
'only' => ['action1', 'action2', 'action3', 'action4'],
'rules' => [
[
'actions' => ['action1', 'action2'],
'allow' => TRUE,
'roles' => ['?'],
],
[
'actions' => ['action3', 'action4'],
'allow' => TRUE,
'roles' => ['@'],
],
],
],
];
}
I see what happened, released a new 5.0.8 version for it (though you may need to wait a bit for composer to pick it up)
Thanks for the heads up
Thank you!
I am receiving this when using a controller that allows certain actions to be accessed by guest users, like this:
I suspect this happens because yiisoft/yii2/filters/AccessRule.php changed the way it verifies permissions. In function 'matchRole', if current user is not guest, it forwards the permission check to its Role:
and it executes Role::checkPermission('?'), which throws the Exception: