Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
lippserd committed Apr 13, 2022
1 parent 75952ee commit 4972b29
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
@@ -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(
3 changes: 2 additions & 1 deletion library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit 4972b29

Please sign in to comment.