Skip to content

Commit 9141cc5

Browse files
authored
Fix #18196: yii\rbac\DbManager::$checkAccessAssignments is now protected
1 parent 6342ad8 commit 9141cc5

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Yii Framework 2 Change Log
1010
- Enh #18236: Allow `yii\filters\RateLimiter` to accept a closure function for the `$user` property in order to assign values on runtime (nadar)
1111
- Bug #18248: Render only one stack trace on console for chained exceptions (mikehaertl)
1212
- Bug #18233: Add PHP 8 support (samdark)
13+
- Enh #18196: `yii\rbac\DbManager::$checkAccessAssignments` is now `protected` (alex-code)
1314
- Bug #18239: Fix support of no-extension files for `FileValidator::validateExtension()` (darkdef)
1415
- Bug #18229: Add flag for recognize SyBase databases on uses pdo_dblib (darkdef)
1516

rbac/DbManager.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ class DbManager extends BaseManager
100100
* @var array auth item parent-child relationships (childName => list of parents)
101101
*/
102102
protected $parents;
103-
103+
/**
104+
* @var array user assignments (user id => Assignment[])
105+
* @since `protected` since 2.0.38
106+
*/
107+
protected $checkAccessAssignments = [];
104108

105109
/**
106110
* Initializes the application component.
@@ -115,18 +119,16 @@ public function init()
115119
}
116120
}
117121

118-
private $_checkAccessAssignments = [];
119-
120122
/**
121123
* {@inheritdoc}
122124
*/
123125
public function checkAccess($userId, $permissionName, $params = [])
124126
{
125-
if (isset($this->_checkAccessAssignments[(string) $userId])) {
126-
$assignments = $this->_checkAccessAssignments[(string) $userId];
127+
if (isset($this->checkAccessAssignments[(string) $userId])) {
128+
$assignments = $this->checkAccessAssignments[(string) $userId];
127129
} else {
128130
$assignments = $this->getAssignments($userId);
129-
$this->_checkAccessAssignments[(string) $userId] = $assignments;
131+
$this->checkAccessAssignments[(string) $userId] = $assignments;
130132
}
131133

132134
if ($this->hasNoAssignments($assignments)) {
@@ -857,7 +859,7 @@ public function assign($role, $userId)
857859
'created_at' => $assignment->createdAt,
858860
])->execute();
859861

860-
unset($this->_checkAccessAssignments[(string) $userId]);
862+
unset($this->checkAccessAssignments[(string) $userId]);
861863
return $assignment;
862864
}
863865

@@ -870,7 +872,7 @@ public function revoke($role, $userId)
870872
return false;
871873
}
872874

873-
unset($this->_checkAccessAssignments[(string) $userId]);
875+
unset($this->checkAccessAssignments[(string) $userId]);
874876
return $this->db->createCommand()
875877
->delete($this->assignmentTable, ['user_id' => (string) $userId, 'item_name' => $role->name])
876878
->execute() > 0;
@@ -885,7 +887,7 @@ public function revokeAll($userId)
885887
return false;
886888
}
887889

888-
unset($this->_checkAccessAssignments[(string) $userId]);
890+
unset($this->checkAccessAssignments[(string) $userId]);
889891
return $this->db->createCommand()
890892
->delete($this->assignmentTable, ['user_id' => (string) $userId])
891893
->execute() > 0;
@@ -970,7 +972,7 @@ public function removeAllRules()
970972
*/
971973
public function removeAllAssignments()
972974
{
973-
$this->_checkAccessAssignments = [];
975+
$this->checkAccessAssignments = [];
974976
$this->db->createCommand()->delete($this->assignmentTable)->execute();
975977
}
976978

@@ -982,7 +984,7 @@ public function invalidateCache()
982984
$this->rules = null;
983985
$this->parents = null;
984986
}
985-
$this->_checkAccessAssignments = [];
987+
$this->checkAccessAssignments = [];
986988
}
987989

988990
public function loadFromCache()

0 commit comments

Comments
 (0)