Imagine this case:
We have a blog with a comment function.
An operation called "editComment" and a task called "editOwnComment". The task has a biz rule like: return (Yii::app()->user->id == $params["comment"]->userId);.
When displaying a post with several comments, foreach comment we check if the user has the right to edit this comment. If he has, we show a little pencil icon:
foreach ($comments as $comment) {
if (Yii::app()->user->checkAccess('editComment',array('comment' => $comment))) {
//display pencil and link to edit
}
}
We'll then expect that all comments, which the user is associated with, will have the pencil icon. But thats not the case.
Because of Yii's caching function, only the first comment will either have a pencil or not, the rest will follow that example.
Is this an issue? It really seems stupid not to re-evaluate the bizrule, when the parameters have changed.
It could be achieved by doing something like this:
public function checkAccess($operation,$params=array(),$allowCaching=true)
{
if($allowCaching && isset($this->_access[$operation]) && $this->_access[$operation]['params'] == $params)
return $this->_access[$operation]['value'];
else {
$this->_access[$operation]['params'] == $params;
return $this->_access[$operation]['value']=Yii::app()->getAuthManager()->checkAccess($operation,$this->getId(),$params);
}
}
But that wouldn't be good enough as you should still be able to cache values for each different set of parameters.

Help














