From 0504de42576cb08a6af7f40246baf254322bd52e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 17 Mar 2021 17:41:56 +0100 Subject: [PATCH] ObjectSuggestions: Properly control filter optimization --- .../Icingadb/Web/Control/SearchBar/ObjectSuggestions.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php b/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php index e3de5c81..636dc018 100644 --- a/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php +++ b/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php @@ -134,6 +134,13 @@ class ObjectSuggestions extends Suggestions $query->filter($inputFilter); } elseif ($searchFilter instanceof Filter\All) { $searchFilter->add($inputFilter); + + // There may be columns part of $searchFilter which target the base table. These must be + // optimized, otherwise they influence what we'll suggest to the user. (i.e. less) + // The $inputFilter on the other hand must not be optimized, which it wouldn't, but since + // we force optimization on its parent chain, we have to negate that. + $searchFilter->metaData()->set('forceOptimization', true); + $inputFilter->metaData()->set('forceOptimization', false); } else { $searchFilter = $inputFilter; }