diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2019-12-05 11:04:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-05 11:04:33 +0100 |
commit | 63cb31542d9db663f627a17278030b18ed61bc6a (patch) | |
tree | 624c5fce9492da4b4f6836a4a1415ba979055af0 /lib/private/Files/Cache | |
parent | 90401e573e44a4a44d4ce1dc47b534cfb4a9ff1f (diff) | |
parent | bf50342c10dd3093417329865008e7be605135c5 (diff) | |
download | nextcloud-server-63cb31542d9db663f627a17278030b18ed61bc6a.tar.gz nextcloud-server-63cb31542d9db663f627a17278030b18ed61bc6a.zip |
Merge pull request #17941 from nextcloud/search-by-owner
Allow filtering the search results to the users home storage
Diffstat (limited to 'lib/private/Files/Cache')
-rw-r--r-- | lib/private/Files/Cache/Cache.php | 5 | ||||
-rw-r--r-- | lib/private/Files/Cache/QuerySearchHelper.php | 8 |
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index a90617f5c53..842704d1471 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -793,7 +793,10 @@ class Cache implements ICache { ->andWhere($builder->expr()->eq('tag.uid', $builder->createNamedParameter($searchQuery->getUser()->getUID()))); } - $query->andWhere($this->querySearchHelper->searchOperatorToDBExpr($builder, $searchQuery->getSearchOperation())); + $searchExpr = $this->querySearchHelper->searchOperatorToDBExpr($builder, $searchQuery->getSearchOperation()); + if ($searchExpr) { + $query->andWhere($searchExpr); + } $this->querySearchHelper->addSearchOrdersToQuery($query, $searchQuery->getOrder()); diff --git a/lib/private/Files/Cache/QuerySearchHelper.php b/lib/private/Files/Cache/QuerySearchHelper.php index 2d9d8f374f7..47380b72ffa 100644 --- a/lib/private/Files/Cache/QuerySearchHelper.php +++ b/lib/private/Files/Cache/QuerySearchHelper.php @@ -88,14 +88,18 @@ class QuerySearchHelper { * @param ISearchOperator $operator */ public function searchOperatorArrayToDBExprArray(IQueryBuilder $builder, array $operators) { - return array_map(function ($operator) use ($builder) { + return array_filter(array_map(function ($operator) use ($builder) { return $this->searchOperatorToDBExpr($builder, $operator); - }, $operators); + }, $operators)); } public function searchOperatorToDBExpr(IQueryBuilder $builder, ISearchOperator $operator) { $expr = $builder->expr(); if ($operator instanceof ISearchBinaryOperator) { + if (count($operator->getArguments()) === 0) { + return null; + } + switch ($operator->getType()) { case ISearchBinaryOperator::OPERATOR_NOT: $negativeOperator = $operator->getArguments()[0]; |