From dd9f593a76983a48f196ed1aa6dd2336922a4b30 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Wed, 5 Jul 2023 11:55:51 +0200 Subject: [PATCH] Fix customvar search suggestions --- .../Icingadb/Web/Control/SearchBar/ObjectSuggestions.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php b/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php index 2506770ba..ad35c7456 100644 --- a/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php +++ b/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php @@ -212,15 +212,16 @@ protected function fetchColumnSuggestions($searchTerm) // Custom variables only after the columns are exhausted and there's actually a chance the user sees them $titleAdded = false; + $parsedArrayVars = []; foreach ($this->getDb()->select($this->queryCustomvarConfig($searchTerm)) as $customVar) { $search = $name = $customVar->flatname; - if (preg_match('/\w+\[(\d+)]$/', $search, $matches)) { - // array vars need to be specifically handled - if ($matches[1] !== '0') { + if (preg_match('/\w+(?:\[(\d*)])+$/', $search, $matches)) { + $name = substr($search, 0, -(strlen($matches[1]) + 2)); + if (isset($parsedArrayVars[$name])) { continue; } - $name = substr($search, 0, -3); + $parsedArrayVars[$name] = true; $search = $name . '[*]'; }