From ff5696e7a6aeb3c4b396546b80073545a7256b1b Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 28 Sep 2015 15:00:03 +0200 Subject: [PATCH 1/2] Do not validate existence of customvar columns Improve performance and solve issues with differences in customvar case sensitivitty among different versions. refs #10172 --- modules/monitoring/library/Monitoring/DataView/DataView.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/DataView/DataView.php b/modules/monitoring/library/Monitoring/DataView/DataView.php index 845aa4db4..97879d53d 100644 --- a/modules/monitoring/library/Monitoring/DataView/DataView.php +++ b/modules/monitoring/library/Monitoring/DataView/DataView.php @@ -185,7 +185,11 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite */ public function isValidFilterTarget($column) { - return in_array($column, $this->getFilterColumns()); + // Customvar + if ($column[0] === '_' && preg_match('/^_(?:host|service)_/', $column)) { + return true; + } + return in_array($column, $this->getColumns()) || in_array($column, $this->getStaticFilterColumns()); } /** From feaa92c491d5b583fb4b4d13c8c8b866b31b2de6 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 28 Sep 2015 16:01:13 +0200 Subject: [PATCH 2/2] Allow passing customvar names in upper and lower case Fix that customvar names are not properly lowercased in all places. refs #10172 --- .../library/Monitoring/Backend/Ido/Query/IdoQuery.php | 2 +- modules/monitoring/library/Monitoring/Controller.php | 2 +- modules/monitoring/library/Monitoring/DataView/DataView.php | 2 +- 3 files changed, 3 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 122e13dc0..1480e2834 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php @@ -832,7 +832,7 @@ abstract class IdoQuery extends DbQuery list($type, $name) = $this->customvarNameToTypeName($customvar); $alias = ($type === 'host' ? 'hcv_' : 'scv_') . $name; - $this->customVars[$customvar] = $alias; + $this->customVars[strtolower($customvar)] = $alias; if ($this->hasJoinedVirtualTable('services')) { $leftcol = 's.' . $type . '_object_id'; diff --git a/modules/monitoring/library/Monitoring/Controller.php b/modules/monitoring/library/Monitoring/Controller.php index 1dc1d28eb..e1c16c854 100644 --- a/modules/monitoring/library/Monitoring/Controller.php +++ b/modules/monitoring/library/Monitoring/Controller.php @@ -82,7 +82,7 @@ class Controller extends IcingaWebController 'service_description', 'servicegroup_name', function ($c) { - return preg_match('/^_(?:host|service)_/', $c); + return preg_match('/^_(?:host|service)_/i', $c); } )); foreach ($this->getRestrictions($name) as $filter) { diff --git a/modules/monitoring/library/Monitoring/DataView/DataView.php b/modules/monitoring/library/Monitoring/DataView/DataView.php index 97879d53d..50cd436fd 100644 --- a/modules/monitoring/library/Monitoring/DataView/DataView.php +++ b/modules/monitoring/library/Monitoring/DataView/DataView.php @@ -186,7 +186,7 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite public function isValidFilterTarget($column) { // Customvar - if ($column[0] === '_' && preg_match('/^_(?:host|service)_/', $column)) { + if ($column[0] === '_' && preg_match('/^_(?:host|service)_/i', $column)) { return true; } return in_array($column, $this->getColumns()) || in_array($column, $this->getStaticFilterColumns());