From 7a8216b0298efa104047a0c4ff599a1aea43e699 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 5 Apr 2022 23:22:30 +0200 Subject: [PATCH] Fix "base model" extraction from getUnions() array Account changes made in commit 4b09a490, which moved "base models" to the end of the getUnions() array. --- library/Icingadb/Common/SearchControls.php | 3 ++- library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) 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(); }