summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2018-01-16 20:21:08 +0100
committerGitHub <noreply@github.com>2018-01-16 20:21:08 +0100
commit4b2e98953b00f9bef9f6c70b36679ae387ce8442 (patch)
treead143d88fc901f8ad79e2b03580f6d79cceb03fb /lib/private
parentc32a13fb5b5f2730c9a87a4eec6bd8118703738c (diff)
parent3a1390fdb7fec732b7d69706e3221d956ce18609 (diff)
downloadnextcloud-server-4b2e98953b00f9bef9f6c70b36679ae387ce8442.tar.gz
nextcloud-server-4b2e98953b00f9bef9f6c70b36679ae387ce8442.zip
Merge pull request #7883 from nextcloud/search-and-13
[13] Support arbitrary number of arguments for d:or and d:and in search queries
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Files/Cache/QuerySearchHelper.php14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/private/Files/Cache/QuerySearchHelper.php b/lib/private/Files/Cache/QuerySearchHelper.php
index 51ecb12a06a..ac64ba5c592 100644
--- a/lib/private/Files/Cache/QuerySearchHelper.php
+++ b/lib/private/Files/Cache/QuerySearchHelper.php
@@ -83,6 +83,16 @@ class QuerySearchHelper {
return false;
}
+ /**
+ * @param IQueryBuilder $builder
+ * @param ISearchOperator $operator
+ */
+ public function searchOperatorArrayToDBExprArray(IQueryBuilder $builder, array $operators) {
+ return array_map(function ($operator) use ($builder) {
+ return $this->searchOperatorToDBExpr($builder, $operator);
+ }, $operators);
+ }
+
public function searchOperatorToDBExpr(IQueryBuilder $builder, ISearchOperator $operator) {
$expr = $builder->expr();
if ($operator instanceof ISearchBinaryOperator) {
@@ -95,9 +105,9 @@ class QuerySearchHelper {
throw new \InvalidArgumentException('Binary operators inside "not" is not supported');
}
case ISearchBinaryOperator::OPERATOR_AND:
- return $expr->andX($this->searchOperatorToDBExpr($builder, $operator->getArguments()[0]), $this->searchOperatorToDBExpr($builder, $operator->getArguments()[1]));
+ return call_user_func_array([$expr, 'andX'], $this->searchOperatorArrayToDBExprArray($builder, $operator->getArguments()));
case ISearchBinaryOperator::OPERATOR_OR:
- return $expr->orX($this->searchOperatorToDBExpr($builder, $operator->getArguments()[0]), $this->searchOperatorToDBExpr($builder, $operator->getArguments()[1]));
+ return call_user_func_array([$expr, 'orX'], $this->searchOperatorArrayToDBExprArray($builder, $operator->getArguments()));
default:
throw new \InvalidArgumentException('Invalid operator type: ' . $operator->getType());
}