diff --git a/library/Icingadb/Common/SearchControls.php b/library/Icingadb/Common/SearchControls.php index e169a07df..88c52bdce 100644 --- a/library/Icingadb/Common/SearchControls.php +++ b/library/Icingadb/Common/SearchControls.php @@ -54,7 +54,8 @@ public function createSearchBar(Query $query, array $preserveParams = null): Sea try { if ($query instanceof UnionQuery) { // TODO: This can't be right. Finally solve this god-damn union-query-model structure!!!1 - $query = $query->getUnions()[0]; + $queries = $query->getUnions(); + $query = end($queries); } $relationPath = $query->getResolver()->qualifyPath( diff --git a/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php b/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php index 2f9eb6ff7..f36d5532d 100644 --- a/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php +++ b/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php @@ -295,7 +295,8 @@ public static function collectFilterColumns(Model $model, Resolver $resolver): G } if ($model instanceof UnionModel) { - $baseModelClass = $model->getUnions()[0][0]; + $queries = $model->getUnions(); + $baseModelClass = end($queries)[0]; $model = new $baseModelClass(); }