Skip to content

Commit

Permalink
Fix "base model" extraction from getUnions() array
Browse files Browse the repository at this point in the history
Account changes made in commit 4b09a490, which moved "base models" to
the end of the getUnions() array.
  • Loading branch information
lippserd committed May 19, 2022
1 parent fbf8743 commit 7a8216b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion library/Icingadb/Common/SearchControls.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit 7a8216b

Please sign in to comment.