From 59d5656bd6f0cb7d1ad5931b9e5326436e7ede91 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 5 Apr 2018 09:57:10 +0200 Subject: [PATCH] Unify the escaping of all metric template macros refs #139 --- library/Graphite/Graphing/Template.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/library/Graphite/Graphing/Template.php b/library/Graphite/Graphing/Template.php index e47cb0c..f8b2f41 100644 --- a/library/Graphite/Graphing/Template.php +++ b/library/Graphite/Graphing/Template.php @@ -67,18 +67,16 @@ class Template $metricsExcluded = 0; foreach ($this->curves as $curveName => $curve) { - $query = $dataSource->select()->from($curve[0]->resolve([ - 'host_name_template' => static::getHostNameTemplate()->resolve([ - 'host.check_command' => $checkCommand, - '' => '$$' - ]), - 'service_name_template' => static::getServiceNameTemplate()->resolve([ - 'service.check_command' => $checkCommand, - '' => '$$' - ]), + $fullMetricTemplate = new MacroTemplate($curve[0]->resolve([ + 'host_name_template' => static::getHostNameTemplate(), + 'service_name_template' => static::getServiceNameTemplate(), '' => '$$' ])); + $query = $dataSource->select()->from($fullMetricTemplate) + ->where('host.check_command', $checkCommand) + ->where('service.check_command', $checkCommand); + foreach ($filter as $key => $value) { $query->where($key, $value); }