From 9b32eabc7dabd0339c48720ff72e4c95112b59b9 Mon Sep 17 00:00:00 2001 From: Petr Macek Date: Tue, 5 May 2026 21:05:50 +0200 Subject: [PATCH 1/2] return back php 7.4 --- monitor_controller.php | 8 ++++---- monitor_render.php | 10 +++++----- poller_functions.php | 40 ++++++++++++++++++++-------------------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/monitor_controller.php b/monitor_controller.php index 7eb2b69..c8925a1 100644 --- a/monitor_controller.php +++ b/monitor_controller.php @@ -431,7 +431,7 @@ function monitorGetZoomDropdownState(bool &$dozoombgndcolor): array { * * @return void */ -function monitorRenderPrimaryFilterRow(array $dashboards, array $monitor_status, array $monitor_view_type, array $monitor_grouping, array $item_rows, int|null $mon_zoom_status): void { +function monitorRenderPrimaryFilterRow(array $dashboards, array $monitor_status, array $monitor_view_type, array $monitor_grouping, array $item_rows, mixed $mon_zoom_status): void { drawFilterDropdown('dashboard', __('Layout', 'monitor'), $dashboards); drawFilterDropdown('status', __('Status', 'monitor'), $monitor_status, $mon_zoom_status); drawFilterDropdown('view', __('View', 'monitor'), $monitor_view_type); @@ -465,7 +465,7 @@ function monitorRenderPrimaryFilterRow(array $dashboards, array $monitor_status, * * @return void */ -function monitorRenderGroupingDropdowns(array $classes, array $criticalities, array $monitor_trim, array $page_refresh_interval, string|null $mon_zoom_size): void { +function monitorRenderGroupingDropdowns(array $classes, array $criticalities, array $monitor_trim, array $page_refresh_interval, mixed $mon_zoom_size): void { drawFilterDropdown('crit', __('Criticality', 'monitor'), $criticalities); if (get_request_var('view') != 'list') { @@ -971,13 +971,13 @@ function validateRequestVars(bool $force = false): void { /** * Load host row and normalize status fields for AJAX tooltip rendering. * - * @param int $id Host id. + * @param int $id|string Host id. * @param array $thold_hosts Threshold host map. * @param array $config Global Cacti config. * * @return array */ -function monitorLoadAjaxStatusHost(int|string $id, array $thold_hosts, array $config): array { +function monitorLoadAjaxStatusHost(mixed $id, array $thold_hosts, array $config): array { $host = db_fetch_row_prepared( 'SELECT * FROM host diff --git a/monitor_render.php b/monitor_render.php index 98c706d..e07063f 100644 --- a/monitor_render.php +++ b/monitor_render.php @@ -89,7 +89,7 @@ function renderDefault(): string { $maxlen = 10; if (get_request_var('view') == 'default') { - $maxlen = db_fetch_cell("SELECT MAX(LENGTH(description)) + $maxlen = (int) db_fetch_cell("SELECT MAX(LENGTH(description)) FROM host AS h $sql_join $sql_where"); @@ -692,11 +692,11 @@ function getHostStatus(array $host, bool $real = false): int { /** * Translate status code into localized display label. * - * @param int $status Monitor status code. + * @param int|string $status Monitor status code. * * @return string */ -function getHostStatusDescription(int|string $status): string { +function getHostStatusDescription(mixed $status): string { global $icolorsdisplay; if (array_key_exists($status, $icolorsdisplay)) { @@ -803,12 +803,12 @@ function getStatusIcon(int $status, string $icon): string { /** * Convert uptime/fail timestamp into compact human-readable duration text. * - * @param string|int $status_time Timestamp string or SNMP uptime ticks. + * @param int|string $status_time Timestamp string or SNMP uptime ticks. * @param bool $seconds Include seconds in output string. * * @return string */ -function monitorPrintHostTime(int|string $status_time, bool $seconds = false): string { +function monitorPrintHostTime(mixed $status_time, bool $seconds = false): string { // If the host is down, make a downtime since message $dt = ''; diff --git a/poller_functions.php b/poller_functions.php index ddb8568..b7daa82 100644 --- a/poller_functions.php +++ b/poller_functions.php @@ -30,11 +30,11 @@ * * @param array $reboot_emails Recipient map keyed by email, then host id. * @param array $alert_emails List of raw email addresses. - * @param int $host_id Host id to associate with each recipient. + * @param int|string $host_id Host id to associate with each recipient. * * @return void */ -function monitorAddEmails(array &$reboot_emails, array $alert_emails, int|string $host_id): void { +function monitorAddEmails(array &$reboot_emails, array $alert_emails, mixd $host_id): void { if (cacti_sizeof($alert_emails)) { foreach ($alert_emails as $email) { $reboot_emails[trim(strtolower($email))][$host_id] = $host_id; @@ -45,14 +45,14 @@ function monitorAddEmails(array &$reboot_emails, array $alert_emails, int|string /** * Add a host id to recipients coming from a notification list id. * - * @param array $reboot_emails Recipient map keyed by email, then host id. - * @param int $notify_list Notification list id. - * @param int $host_id Host id to add. + * @param array $reboot_emails Recipient map keyed by email, then host id. + * @param int|string|null $notify_list Notification list id. + * @param int|string $host_id Host id to add. * @param array $notification_lists Map of list id to comma-delimited emails. * * @return void */ -function monitorAddNotificationList(array &$reboot_emails, int|string|null $notify_list, int|string $host_id, array $notification_lists): void { +function monitorAddNotificationList(array &$reboot_emails, mixed $notify_list, mixed $host_id, array $notification_lists): void { if ($notify_list !== null && $notify_list > 0 && isset($notification_lists[$notify_list])) { $emails = explode(',', $notification_lists[$notify_list]); monitorAddEmails($reboot_emails, $emails, $host_id); @@ -130,14 +130,14 @@ function getNotificationListsMap(): array { /** * Add reboot recipients based on host threshold notification settings. * - * @param array $reboot_emails Recipient map keyed by email, then host id. - * @param int $host_id Host id being processed. - * @param array $alert_emails Global alert email list. - * @param array $notification_lists Map of notification list id to emails. + * @param array $reboot_emails Recipient map keyed by email, then host id. + * @param int|string $host_id Host id being processed. + * @param array $alert_emails Global alert email list. + * @param array $notification_lists Map of notification list id to emails. * * @return void */ -function addTholdRebootRecipients(array &$reboot_emails, int|string $host_id, array $alert_emails, array $notification_lists): void { +function addTholdRebootRecipients(array &$reboot_emails, mixed $host_id, array $alert_emails, array $notification_lists): void { $notify = db_fetch_row_prepared( 'SELECT thold_send_email, thold_host_email FROM host @@ -490,11 +490,11 @@ function normalizeAndLogNotificationHosts(array &$alert_hosts, array &$warn_host /** * Build shared intro copy for ping threshold email and text output. * - * @param int $freq Resend frequency in minutes. + * @param int|string $freq Resend frequency in minutes. * * @return array{string, string} */ -function buildPingNotificationIntro(int|string $freq): array { +function buildPingNotificationIntro(mixed $freq): array { $body = '

' . __(MONITOR_PING_NOTIFICATION_SUBJECT, 'monitor') . '

' . PHP_EOL; $body_txt = __(MONITOR_PING_NOTIFICATION_SUBJECT, 'monitor') . PHP_EOL; @@ -819,15 +819,15 @@ function addGroupedNotificationEntry(string $type, array $entry, array &$global_ /** * Query and group threshold-breached hosts for one severity type. * - * @param string $type Severity key (`alert` or `warn`). - * @param int $criticality Minimum criticality threshold. - * @param array $global_list Global grouped bucket, updated in place. - * @param array $notify_list Per-list grouped bucket, updated in place. - * @param array $lists Set of notification list ids, updated in place. + * @param int|string $type Severity key (`alert` or `warn`). + * @param int $criticality Minimum criticality threshold. + * @param array $global_list Global grouped bucket, updated in place. + * @param array $notify_list Per-list grouped bucket, updated in place. + * @param array $lists Set of notification list ids, updated in place. * * @return void */ -function getHostsByListType(string $type, int|string $criticality, array &$global_list, array &$notify_list, array &$lists): void { +function getHostsByListType(string $type, mixed $criticality, array &$global_list, array &$notify_list, array &$lists): void { $last_time = date(MONITOR_DATE_TIME_FORMAT, time() - read_config_option('monitor_resend_frequency') * 60); $hosts = db_fetch_cell_prepared( @@ -954,7 +954,7 @@ function flattenLists(array &$global_list, array &$notify_list): void { * * @return void */ -function addEmailsToNotificationMap(array &$notification_emails, array $emails, string|int $scope_key): void { +function addEmailsToNotificationMap(array &$notification_emails, array $emails, mixed $scope_key): void { foreach ($emails as $user) { $user = trim($user); From 863b92858769c259098853f40fb6d9ca7f4059e8 Mon Sep 17 00:00:00 2001 From: Petr Macek Date: Tue, 5 May 2026 21:16:19 +0200 Subject: [PATCH 2/2] fixer --- poller_functions.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/poller_functions.php b/poller_functions.php index b7daa82..df0c822 100644 --- a/poller_functions.php +++ b/poller_functions.php @@ -28,9 +28,9 @@ /** * Add a host id to each recipient entry in the reboot recipient map. * - * @param array $reboot_emails Recipient map keyed by email, then host id. - * @param array $alert_emails List of raw email addresses. - * @param int|string $host_id Host id to associate with each recipient. + * @param array $reboot_emails Recipient map keyed by email, then host id. + * @param array $alert_emails List of raw email addresses. + * @param int|string $host_id Host id to associate with each recipient. * * @return void */ @@ -48,7 +48,7 @@ function monitorAddEmails(array &$reboot_emails, array $alert_emails, mixd $host * @param array $reboot_emails Recipient map keyed by email, then host id. * @param int|string|null $notify_list Notification list id. * @param int|string $host_id Host id to add. - * @param array $notification_lists Map of list id to comma-delimited emails. + * @param array $notification_lists Map of list id to comma-delimited emails. * * @return void */