0
0
Fork 0
mirror of https://github.com/nextcloud/server.git synced 2025-02-12 12:09:14 +00:00
nextcloud_server/lib/private/Files/Search/QueryOptimizer/ReplacingOptimizerStep.php
Robin Appelman 3971313d4c fix: don't short circuit query optimizer
Signed-off-by: Robin Appelman <robin@icewind.nl>
2024-03-04 14:25:52 +01:00

33 lines
904 B
PHP

<?php
namespace OC\Files\Search\QueryOptimizer;
use OC\Files\Search\SearchBinaryOperator;
use OCP\Files\Search\ISearchOperator;
/**
* Optimizer step that can replace the $operator altogether instead of just modifying it
* These steps need some extra logic to properly replace the arguments of binary operators
*/
class ReplacingOptimizerStep extends QueryOptimizerStep {
/**
* Allow optimizer steps to modify query operators
*
* Returns true if the reference $operator points to a new value
*/
public function processOperator(ISearchOperator &$operator): bool {
if ($operator instanceof SearchBinaryOperator) {
$modified = false;
$arguments = $operator->getArguments();
foreach ($arguments as &$argument) {
if ($this->processOperator($argument)) {
$modified = true;
}
}
if ($modified) {
$operator->setArguments($arguments);
}
}
return false;
}
}