Skip to content

Commit

Permalink
Fix customvar search suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
yhabteab authored and nilmerg committed Jul 5, 2023
1 parent ca57b19 commit 96470ea
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 . '[*]';
}

Expand Down

0 comments on commit 96470ea

Please sign in to comment.