mirror of
https://github.com/nextcloud/server.git
synced 2026-11-21 12:25:08 +01:00
Fix the following expression: NOT (mimetype = png OR mimetype = jpeg) with now is converted to: mimetype != png AND mimetype != jpeg Signed-off-by: Carl Schwan <carl@carlschwan.eu>
43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
/**
|
|
* SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
namespace OC\Files\Search\QueryOptimizer;
|
|
|
|
use OCP\Files\Search\ISearchOperator;
|
|
|
|
class QueryOptimizer {
|
|
/** @var QueryOptimizerStep[] */
|
|
private $steps = [];
|
|
|
|
public function __construct() {
|
|
// note that the order here is relevant
|
|
$this->steps = [
|
|
new PushDownNegation(),
|
|
new PathPrefixOptimizer(),
|
|
new MergeDistributiveOperations(),
|
|
new FlattenSingleArgumentBinaryOperation(),
|
|
new FlattenNestedBool(),
|
|
new OrEqualsToIn(),
|
|
new FlattenNestedBool(),
|
|
new SplitLargeIn(),
|
|
// SplitLargeIn can turn a `not (in (...))` into `not (or (in (...), in (...)))`, which
|
|
// needs pushing down again before it reaches the query builder.
|
|
new PushDownNegation(),
|
|
];
|
|
}
|
|
|
|
public function processOperator(ISearchOperator &$operator) {
|
|
foreach ($this->steps as $step) {
|
|
$step->inspectOperator($operator);
|
|
}
|
|
foreach ($this->steps as $step) {
|
|
$step->processOperator($operator);
|
|
}
|
|
}
|
|
}
|