summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2021-03-18 17:16:28 +0100
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2021-03-23 13:41:11 +0000
commit2500d296c5222942f71b040b9a96c56fb3e8dbcb (patch)
treef937b68c6c50261dd0a6fc150753195507d789d6 /lib/private
parentd2245734d4a9427c4f03f3568b2361728e3c42fd (diff)
downloadnextcloud-server-2500d296c5222942f71b040b9a96c56fb3e8dbcb.tar.gz
nextcloud-server-2500d296c5222942f71b040b9a96c56fb3e8dbcb.zip
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')
-rw-r--r--lib/private/Files/Cache/Cache.php12
-rw-r--r--lib/private/Files/Search/SearchQuery.php8
2 files changed, 12 insertions, 8 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;
}
/**
diff --git a/lib/private/Files/Search/SearchQuery.php b/lib/private/Files/Search/SearchQuery.php
index b7b8b801104..091fe57d21b 100644
--- a/lib/private/Files/Search/SearchQuery.php
+++ b/lib/private/Files/Search/SearchQuery.php
@@ -37,7 +37,7 @@ class SearchQuery implements ISearchQuery {
private $offset;
/** @var ISearchOrder[] */
private $order;
- /** @var IUser */
+ /** @var ?IUser */
private $user;
private $limitToHome;
@@ -48,7 +48,7 @@ class SearchQuery implements ISearchQuery {
* @param int $limit
* @param int $offset
* @param array $order
- * @param IUser $user
+ * @param ?IUser $user
* @param bool $limitToHome
*/
public function __construct(
@@ -56,7 +56,7 @@ class SearchQuery implements ISearchQuery {
int $limit,
int $offset,
array $order,
- IUser $user,
+ ?IUser $user = null,
bool $limitToHome = false
) {
$this->searchOperation = $searchOperation;
@@ -96,7 +96,7 @@ class SearchQuery implements ISearchQuery {
}
/**
- * @return IUser
+ * @return ?IUser
*/
public function getUser() {
return $this->user;