From 5c1cdbc1c8f6c26b542c96a924d21aa3e896723e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 17 Jun 2015 10:00:29 +0200 Subject: [PATCH] IdoQuery: Join hosts and services automatically if required for customvars refs #9009 fixes #9426 --- .../library/Monitoring/Backend/Ido/Query/IdoQuery.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php index 6d0f418da..3ee32b40b 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php @@ -634,12 +634,14 @@ abstract class IdoQuery extends DbQuery $this->customVars[$customvar] = $alias; - // TODO: extend if we allow queries with only hosts / only services - // ($leftcol s.host_object_id vs h.host_object_id if ($this->hasJoinedVirtualTable('services')) { $leftcol = 's.' . $type . '_object_id'; + } elseif ($type === 'service') { + $this->requireVirtualTable('services'); + $leftcol = 's.service_object_id'; } else { - $leftcol = 'h.' . $type . '_object_id'; + $this->requireVirtualTable('hosts'); + $leftcol = 'h.host_object_id'; } $joinOn = sprintf(