From f00f439aa7f4368ce93bcab35fc62b6972b48576 Mon Sep 17 00:00:00 2001 From: Vincent Gerris Date: Sat, 23 Mar 2024 14:44:10 +0100 Subject: [PATCH 1/2] fix deprecation for empty parameter for strpos method Signed-off-by: Markus Opolka --- application/controllers/IcingadbimgController.php | 2 +- library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/application/controllers/IcingadbimgController.php b/application/controllers/IcingadbimgController.php index 5b44581..9942404 100644 --- a/application/controllers/IcingadbimgController.php +++ b/application/controllers/IcingadbimgController.php @@ -66,7 +66,7 @@ public function init() if ($this->hasParam('timerangeto')) { $this->timerangeto = urldecode($this->getParam('timerangeto')); } else { - $this->timerangeto = strpos($this->timerange, '/') ? 'now-' . $this->timerange : "now"; + $this->timerangeto = strpos($this->timerange ?? '', '/') ? 'now-' . $this->timerange ?? '' : "now"; } $this->cacheTime = $this->hasParam('cachetime') ? $this->getParam('cachetime') : 300; diff --git a/library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php b/library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php index dc8c1f1..64fb453 100644 --- a/library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php +++ b/library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php @@ -236,7 +236,7 @@ private function getGraphConf($serviceName, $serviceCommand = null): ?self $this->timerange = Url::fromRequest()->hasParam('timerange') ? 'now-' . urldecode(Url::fromRequest()->getParam('timerange')) : 'now-' . $this->getGraphConfigOption($serviceName, 'timerange', $this->timerange); - $this->timerangeto = strpos($this->timerange, '/') ? $this->timerange : $this->timerangeto; + $this->timerangeto = strpos($this->timerange ?? '', '/') ? $this->timerange : $this->timerangeto; } $this->height = $this->getGraphConfigOption($serviceName, 'height', $this->height); From 9c50656fb548c167dc2cf7fb2925c3cd880affb7 Mon Sep 17 00:00:00 2001 From: Markus Opolka Date: Thu, 14 Nov 2024 17:03:46 +0100 Subject: [PATCH 2/2] Fix some dynamic properties for PHP8.2 --- application/controllers/IcingadbimgController.php | 13 +++++++++---- application/controllers/IcingadbshowController.php | 2 ++ .../ProvidedHook/Icingadb/IcingaDbGrapher.php | 7 +++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/application/controllers/IcingadbimgController.php b/application/controllers/IcingadbimgController.php index 9942404..489c32c 100644 --- a/application/controllers/IcingadbimgController.php +++ b/application/controllers/IcingadbimgController.php @@ -19,7 +19,6 @@ use ipl\Stdlib\Filter; use ipl\Web\Url; -#[\AllowDynamicProperties] class IcingadbimgController extends IcingadbGrafanaController { protected $host; @@ -49,7 +48,13 @@ class IcingadbimgController extends IcingadbGrafanaController protected $cacheTime; protected $defaultdashboarduid; protected $refresh = "yes"; - + protected $customVars; + protected $timerangeto; + protected $object; + protected $dashboard; + protected $dashboarduid; + protected $panelId; + protected $orgId; public function init() { @@ -326,7 +331,7 @@ private function getMyimageHtml($serviceName, $hostName, &$imageHtml) return false; } - $this->pngUrl = sprintf( + $pngUrl = sprintf( '%s://%s/render/d-solo/%s/%s?var-hostname=%s&var-service=%s&var-command=%s%s&panelId=%s&orgId=%s' . '&width=%s&height=%s&theme=%s&from=%s&to=%s', $this->protocol, @@ -349,7 +354,7 @@ private function getMyimageHtml($serviceName, $hostName, &$imageHtml) // fetch image with curl $curl_handle = curl_init(); $curl_opts = array( - CURLOPT_URL => $this->pngUrl, + CURLOPT_URL => $pngUrl, CURLOPT_CONNECTTIMEOUT => 2, CURLOPT_FOLLOWLOCATION => true, CURLOPT_RETURNTRANSFER => true, diff --git a/application/controllers/IcingadbshowController.php b/application/controllers/IcingadbshowController.php index eb533bd..48bf123 100644 --- a/application/controllers/IcingadbshowController.php +++ b/application/controllers/IcingadbshowController.php @@ -31,6 +31,8 @@ class IcingadbshowController extends IcingadbGrafanaController protected $showFullscreen; protected $host; protected $custvardisable = "grafana_graph_disable"; + protected $config; + protected $object; public function init() { diff --git a/library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php b/library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php index 64fb453..5cdc4f7 100644 --- a/library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php +++ b/library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php @@ -68,6 +68,13 @@ trait IcingaDbGrapher protected $grafanaVersion = "0"; protected $defaultdashboarduid; protected $object; + protected $permission; + protected $dashboard; + protected $dashboarduid; + protected $panelId; + protected $orgId; + protected $customVars; + protected $pngUrl; protected function init() {