From 9be9d072f1f62a84bc92950832cd9c6342e4e483 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Mon, 4 Sep 2023 13:46:23 +0200 Subject: [PATCH 1/2] X509\Sni: Ping DB connection before using it --- library/Icingadb/ProvidedHook/X509/Sni.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/Icingadb/ProvidedHook/X509/Sni.php b/library/Icingadb/ProvidedHook/X509/Sni.php index ef95c2ec6..4e42edbea 100644 --- a/library/Icingadb/ProvidedHook/X509/Sni.php +++ b/library/Icingadb/ProvidedHook/X509/Sni.php @@ -22,6 +22,8 @@ class Sni extends SniHook */ public function getHosts(Filter $filter = null): Generator { + $this->getDb()->ping(); + $queryHost = Host::on($this->getDb()); $queryHost->getSelectBase(); From 0a31addffebb211dd1755c336ea13167b85cf233 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Tue, 12 Sep 2023 13:55:35 +0200 Subject: [PATCH 2/2] X509\Sni: Cleanup some codes --- library/Icingadb/ProvidedHook/X509/Sni.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/library/Icingadb/ProvidedHook/X509/Sni.php b/library/Icingadb/ProvidedHook/X509/Sni.php index 4e42edbea..6f20a7df6 100644 --- a/library/Icingadb/ProvidedHook/X509/Sni.php +++ b/library/Icingadb/ProvidedHook/X509/Sni.php @@ -24,17 +24,12 @@ public function getHosts(Filter $filter = null): Generator { $this->getDb()->ping(); - $queryHost = Host::on($this->getDb()); - - $queryHost->getSelectBase(); - - $hostStatusCols = [ - 'host_name' => 'name', - 'host_address' => 'address', - 'host_address6' => 'address6' - ]; - - $queryHost = $queryHost->columns($hostStatusCols); + $queryHost = Host::on($this->getDb()) + ->columns([ + 'host_name' => 'name', + 'host_address' => 'address', + 'host_address6' => 'address6' + ]); $this->applyRestrictions($queryHost);