diff options
author | Robin Appelman <robin@icewind.nl> | 2021-03-18 19:16:28 +0300 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2021-03-18 19:16:28 +0300 |
commit | 50e374c12fce6b0aeee62f42edcd18a573537a8f (patch) | |
tree | d832c977b69aeda8ab22f21a209ccb485d129e64 /lib/private/Files/Cache | |
parent | f8bca545df7cc31b4ace6f9af9294cc182bd401e (diff) |
only require user to be set in a query that handles tags
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Files/Cache')
-rw-r--r-- | lib/private/Files/Cache/Cache.php | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index a18fddcbdeb..59e50164ef6 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -198,10 +198,10 @@ class Cache implements ICache { } $data['permissions'] = (int)$data['permissions']; if (isset($data['creation_time'])) { - $data['creation_time'] = (int) $data['creation_time']; + $data['creation_time'] = (int)$data['creation_time']; } if (isset($data['upload_time'])) { - $data['upload_time'] = (int) $data['upload_time']; + $data['upload_time'] = (int)$data['upload_time']; } return new CacheEntry($data); } @@ -841,6 +841,10 @@ class Cache implements ICache { $query->whereStorageId(); if ($this->querySearchHelper->shouldJoinTags($searchQuery->getSearchOperation())) { + $user = $searchQuery->getUser(); + if ($user === null) { + throw new \InvalidArgumentException("Searching by tag requires the user to be set in the query"); + } $query ->innerJoin('file', 'vcategory_to_object', 'tagmap', $builder->expr()->eq('file.fileid', 'tagmap.objid')) ->innerJoin('tagmap', 'vcategory', 'tag', $builder->expr()->andX( @@ -848,7 +852,7 @@ class Cache implements ICache { $builder->expr()->eq('tagmap.categoryid', 'tag.id') )) ->andWhere($builder->expr()->eq('tag.type', $builder->createNamedParameter('files'))) - ->andWhere($builder->expr()->eq('tag.uid', $builder->createNamedParameter($searchQuery->getUser()->getUID()))); + ->andWhere($builder->expr()->eq('tag.uid', $builder->createNamedParameter($user->getUID()))); } $searchExpr = $this->querySearchHelper->searchOperatorToDBExpr($builder, $searchQuery->getSearchOperation()); @@ -1031,7 +1035,7 @@ class Cache implements ICache { return null; } - return (string) $path; + return (string)$path; } /** |