diff options
author | Joas Schilling <coding@schilljs.com> | 2019-02-22 11:37:04 +0100 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2019-03-01 20:56:59 +0100 |
commit | 411350540d137d80c71f1382a667a794dc24821f (patch) | |
tree | a0657fc737804597636d82764a893e241b6c19a1 /lib/private/Collaboration | |
parent | 066238a99074e27122901f4364e26acdfcb4e6dc (diff) | |
download | nextcloud-server-411350540d137d80c71f1382a667a794dc24821f.tar.gz nextcloud-server-411350540d137d80c71f1382a667a794dc24821f.zip |
Also cache the resource type because it is part of the identifier
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Collaboration')
-rw-r--r-- | lib/private/Collaboration/Resources/Manager.php | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/private/Collaboration/Resources/Manager.php b/lib/private/Collaboration/Resources/Manager.php index b95747c61de..3c2714b76a6 100644 --- a/lib/private/Collaboration/Resources/Manager.php +++ b/lib/private/Collaboration/Resources/Manager.php @@ -200,6 +200,7 @@ class Manager implements IManager { 'r', self::TABLE_ACCESS_CACHE, 'a', $query->expr()->andX( $query->expr()->eq('r.resource_id', 'a.resource_id'), + $query->expr()->eq('r.resource_type', 'a.resource_type'), $query->expr()->eq('a.user_id', $query->createNamedParameter($userId, IQueryBuilder::PARAM_STR)) ) ) @@ -237,6 +238,7 @@ class Manager implements IManager { 'r', self::TABLE_ACCESS_CACHE, 'a', $query->expr()->andX( $query->expr()->eq('r.resource_id', 'a.resource_id'), + $query->expr()->eq('r.resource_type', 'a.resource_type'), $query->expr()->eq('a.user_id', $query->createNamedParameter($userId, IQueryBuilder::PARAM_STR)) ) ) @@ -362,6 +364,7 @@ class Manager implements IManager { $query->select('access') ->from(self::TABLE_ACCESS_CACHE) ->where($query->expr()->eq('resource_id', $query->createNamedParameter($resource->getId(), IQueryBuilder::PARAM_STR))) + ->andWhere($query->expr()->eq('resource_type', $query->createNamedParameter($resource->getType(), IQueryBuilder::PARAM_STR))) ->andWhere($query->expr()->eq('user_id', $query->createNamedParameter($userId, IQueryBuilder::PARAM_STR))) ->setMaxResults(1); @@ -403,6 +406,7 @@ class Manager implements IManager { ->values([ 'user_id' => $query->createNamedParameter($userId), 'resource_id' => $query->createNamedParameter($resource->getId()), + 'resource_type' => $query->createNamedParameter($resource->getType()), 'access' => $query->createNamedParameter($access), ]); try { @@ -440,7 +444,8 @@ class Manager implements IManager { $query = $this->connection->getQueryBuilder(); $query->delete(self::TABLE_ACCESS_CACHE) - ->where($query->expr()->eq('resource_id', $query->createNamedParameter($resource->getId()))); + ->where($query->expr()->eq('resource_id', $query->createNamedParameter($resource->getId()))) + ->andWhere($query->expr()->eq('resource_type', $query->createNamedParameter($resource->getType(), IQueryBuilder::PARAM_STR))); $query->execute(); foreach ($resource->getCollections() as $collection) { @@ -456,6 +461,14 @@ class Manager implements IManager { $query->execute(); } + public function invalidateAccessCacheForProvider(IProvider $provider): void { + $query = $this->connection->getQueryBuilder(); + + $query->delete(self::TABLE_ACCESS_CACHE) + ->where($query->expr()->eq('resource_type', $query->createNamedParameter($provider->getType(), IQueryBuilder::PARAM_STR))); + $query->execute(); + } + public function invalidateAccessCacheForResourceByUser(IResource $resource, ?IUser $user): void { $query = $this->connection->getQueryBuilder(); $userId = $user instanceof IUser ? $user->getUID() : ''; @@ -480,6 +493,16 @@ class Manager implements IManager { $query->execute(); } + public function invalidateAccessCacheForProviderByUser(IProvider $provider, ?IUser $user): void { + $query = $this->connection->getQueryBuilder(); + $userId = $user instanceof IUser ? $user->getUID() : ''; + + $query->delete(self::TABLE_ACCESS_CACHE) + ->where($query->expr()->eq('resource_type', $query->createNamedParameter($provider->getType(), IQueryBuilder::PARAM_STR))) + ->andWhere($query->expr()->eq('user_id', $query->createNamedParameter($userId))); + $query->execute(); + } + /** * @param IProvider $provider */ |