mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 21:41:19 +08:00
Fix #18196: yii\rbac\DbManager::$checkAccessAssignments is now protected
This commit is contained in:
@ -100,7 +100,11 @@ class DbManager extends BaseManager
|
||||
* @var array auth item parent-child relationships (childName => list of parents)
|
||||
*/
|
||||
protected $parents;
|
||||
|
||||
/**
|
||||
* @var array user assignments (user id => Assignment[])
|
||||
* @since `protected` since 2.0.38
|
||||
*/
|
||||
protected $checkAccessAssignments = [];
|
||||
|
||||
/**
|
||||
* Initializes the application component.
|
||||
@ -115,18 +119,16 @@ class DbManager extends BaseManager
|
||||
}
|
||||
}
|
||||
|
||||
private $_checkAccessAssignments = [];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function checkAccess($userId, $permissionName, $params = [])
|
||||
{
|
||||
if (isset($this->_checkAccessAssignments[(string) $userId])) {
|
||||
$assignments = $this->_checkAccessAssignments[(string) $userId];
|
||||
if (isset($this->checkAccessAssignments[(string) $userId])) {
|
||||
$assignments = $this->checkAccessAssignments[(string) $userId];
|
||||
} else {
|
||||
$assignments = $this->getAssignments($userId);
|
||||
$this->_checkAccessAssignments[(string) $userId] = $assignments;
|
||||
$this->checkAccessAssignments[(string) $userId] = $assignments;
|
||||
}
|
||||
|
||||
if ($this->hasNoAssignments($assignments)) {
|
||||
@ -857,7 +859,7 @@ class DbManager extends BaseManager
|
||||
'created_at' => $assignment->createdAt,
|
||||
])->execute();
|
||||
|
||||
unset($this->_checkAccessAssignments[(string) $userId]);
|
||||
unset($this->checkAccessAssignments[(string) $userId]);
|
||||
return $assignment;
|
||||
}
|
||||
|
||||
@ -870,7 +872,7 @@ class DbManager extends BaseManager
|
||||
return false;
|
||||
}
|
||||
|
||||
unset($this->_checkAccessAssignments[(string) $userId]);
|
||||
unset($this->checkAccessAssignments[(string) $userId]);
|
||||
return $this->db->createCommand()
|
||||
->delete($this->assignmentTable, ['user_id' => (string) $userId, 'item_name' => $role->name])
|
||||
->execute() > 0;
|
||||
@ -885,7 +887,7 @@ class DbManager extends BaseManager
|
||||
return false;
|
||||
}
|
||||
|
||||
unset($this->_checkAccessAssignments[(string) $userId]);
|
||||
unset($this->checkAccessAssignments[(string) $userId]);
|
||||
return $this->db->createCommand()
|
||||
->delete($this->assignmentTable, ['user_id' => (string) $userId])
|
||||
->execute() > 0;
|
||||
@ -970,7 +972,7 @@ class DbManager extends BaseManager
|
||||
*/
|
||||
public function removeAllAssignments()
|
||||
{
|
||||
$this->_checkAccessAssignments = [];
|
||||
$this->checkAccessAssignments = [];
|
||||
$this->db->createCommand()->delete($this->assignmentTable)->execute();
|
||||
}
|
||||
|
||||
@ -982,7 +984,7 @@ class DbManager extends BaseManager
|
||||
$this->rules = null;
|
||||
$this->parents = null;
|
||||
}
|
||||
$this->_checkAccessAssignments = [];
|
||||
$this->checkAccessAssignments = [];
|
||||
}
|
||||
|
||||
public function loadFromCache()
|
||||
|
||||
Reference in New Issue
Block a user