Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit c9f6c40

Browse files
committed
Fix auto-apply profile and cache
1 parent 91b0292 commit c9f6c40

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

core/src/core/src/pydio/Core/Services/RolesService.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ public static function updateRole($roleObject, $userObject = null)
146146
{
147147
ConfService::getConfStorageImpl()->updateRole($roleObject, $userObject);
148148
CacheService::saveWithTimestamp(AJXP_CACHE_SERVICE_NS_SHARED, "pydio:role:".$roleObject->getId(), $roleObject);
149+
$profiles = $roleObject->listAutoApplies();
150+
foreach($profiles as $profile){
151+
CacheService::saveWithTimestamp(AJXP_CACHE_SERVICE_NS_SHARED, "pydio:profile:".$profile, time());
152+
}
149153
ConfService::getInstance()->invalidateLoadedRepositories();
150154
$roleId = $roleObject->getId();
151155
if(strpos($roleId, "AJXP_GRP_/") === 0){

core/src/core/src/pydio/Core/Services/UsersService.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ public static function getUserById($userId, $checkExists = true){
8585
// Try to get from cache
8686
$test = CacheService::fetch(AJXP_CACHE_SERVICE_NS_SHARED, "pydio:user:" . $userId);
8787
if($test !== false && $test instanceof UserInterface){
88-
// Second check : if roles were updated in cache
88+
// Second check : if roles were updated in cache, or maybe profile with auto-apply feature
8989
$roleCacheIds = array_map(function($k){ return "pydio:role:".$k; }, $test->getRolesKeys());
90+
$profile = $test->getProfile();
91+
if(!empty($profile)) $roleCacheIds[] = "pydio:profile:".$profile;
9092
$test = CacheService::fetchWithTimestamps(AJXP_CACHE_SERVICE_NS_SHARED, "pydio:user:".$userId, $roleCacheIds);
9193
if($test !== false){
9294
if($test->getPersonalRole() === null){
@@ -180,6 +182,17 @@ public static function getRepositoriesForUser($user, $includeShared = true, $det
180182

181183
}
182184

185+
/**
186+
* @param string $userId
187+
* @param RepositoryInterface[] $repoList
188+
*/
189+
private function setInCache($userId, $repoList){
190+
191+
$this->repositoriesCache[$userId] = $repoList;
192+
SessionService::updateLoadedRepositories($repoList);
193+
194+
}
195+
183196
/**
184197
* @param $userId
185198
* @return mixed|null|\Pydio\Core\Model\RepositoryInterface[]
@@ -203,17 +216,6 @@ private function getFromCaches($userId){
203216

204217
}
205218

206-
/**
207-
* @param string $userId
208-
* @param RepositoryInterface[] $repoList
209-
*/
210-
private function setInCache($userId, $repoList){
211-
212-
$this->repositoriesCache[$userId] = $repoList;
213-
SessionService::updateLoadedRepositories($repoList);
214-
215-
}
216-
217219
public static function invalidateCache(){
218220

219221
self::instance()->repositoriesCache = [];

0 commit comments

Comments
 (0)