From 5531d57db74aadba95901b36058f6a8ba1db7c03 Mon Sep 17 00:00:00 2001 From: Petr Macek Date: Thu, 15 Oct 2026 14:55:36 +0200 Subject: [PATCH 1/3] fix incorrect include --- servcheck_process.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/servcheck_process.php b/servcheck_process.php index dce605d..6700d5b 100644 --- a/servcheck_process.php +++ b/servcheck_process.php @@ -316,7 +316,13 @@ function servcheck_run_test(array $test, bool $force): void { } if (api_plugin_is_enabled('maint')) { - require_once($config['base_path'] . '/plugins/maint/functions.php'); + if (file_exists(require_once($config['base_path'] . '/plugins/maint/functions.php')) { + require_once($config['base_path'] . '/plugins/maint/functions.php'); + } else if (file_exists(require_once($config['base_path'] . '/plugins/maint/includes/functions.php')) { + require_once($config['base_path'] . '/plugins/maint/includes/functions.php'); + } else { + cacti_log('ERROR: cannot include maint functions', false, 'SERVCHECK'); + } } if (function_exists('plugin_maint_check_servcheck_test')) { From bc23e8f80a49406d42e26c9ec8d714979e325edf Mon Sep 17 00:00:00 2001 From: Petr Macek Date: Thu, 15 Oct 2026 15:01:49 +0200 Subject: [PATCH 2/3] fix syntax error --- servcheck_process.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/servcheck_process.php b/servcheck_process.php index 6700d5b..79d6a7a 100644 --- a/servcheck_process.php +++ b/servcheck_process.php @@ -316,9 +316,9 @@ function servcheck_run_test(array $test, bool $force): void { } if (api_plugin_is_enabled('maint')) { - if (file_exists(require_once($config['base_path'] . '/plugins/maint/functions.php')) { + if (file_exists(require_once($config['base_path'] . '/plugins/maint/functions.php'))) { require_once($config['base_path'] . '/plugins/maint/functions.php'); - } else if (file_exists(require_once($config['base_path'] . '/plugins/maint/includes/functions.php')) { + } else if (file_exists(require_once($config['base_path'] . '/plugins/maint/includes/functions.php'))) { require_once($config['base_path'] . '/plugins/maint/includes/functions.php'); } else { cacti_log('ERROR: cannot include maint functions', false, 'SERVCHECK'); From cebedc247e9a0cadc8532dfae9f05df7af76178f Mon Sep 17 00:00:00 2001 From: TheWitness Date: Thu, 15 Oct 2026 09:12:16 -0400 Subject: [PATCH 3/3] Fix maint include logic and allowlist poller for patch-coverage The maint include used file_exists(require_once(...)), which evaluates require_once first (including the file as a side effect, or fataling when it is absent) and then tests file_exists() on its return value. Replace it with a straightforward file_exists() probe that prefers the relocated plugins/maint/includes/functions.php and falls back to the legacy plugins/maint/functions.php. Also add servcheck_process.php to the patch-coverage unmeasured allowlist: it is a CLI/daemon poller entry point (shebang, chdir + include, pcntl signal handling) that cannot be loaded into the isolated unit process, so it can never appear in the Clover report. This clears the failing 'changed production PHP files are not measured or allowlisted' gate. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- servcheck_process.php | 6 +++--- tests/bin/patch-coverage.php | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/servcheck_process.php b/servcheck_process.php index 79d6a7a..e34be4f 100644 --- a/servcheck_process.php +++ b/servcheck_process.php @@ -316,10 +316,10 @@ function servcheck_run_test(array $test, bool $force): void { } if (api_plugin_is_enabled('maint')) { - if (file_exists(require_once($config['base_path'] . '/plugins/maint/functions.php'))) { - require_once($config['base_path'] . '/plugins/maint/functions.php'); - } else if (file_exists(require_once($config['base_path'] . '/plugins/maint/includes/functions.php'))) { + if (file_exists($config['base_path'] . '/plugins/maint/includes/functions.php')) { require_once($config['base_path'] . '/plugins/maint/includes/functions.php'); + } else if (file_exists($config['base_path'] . '/plugins/maint/functions.php')) { + require_once($config['base_path'] . '/plugins/maint/functions.php'); } else { cacti_log('ERROR: cannot include maint functions', false, 'SERVCHECK'); } diff --git a/tests/bin/patch-coverage.php b/tests/bin/patch-coverage.php index f9b08b2..6c567ed 100644 --- a/tests/bin/patch-coverage.php +++ b/tests/bin/patch-coverage.php @@ -162,6 +162,7 @@ function changed_lines($base_ref) { $unmeasured_allowlist = [ 'servcheck_ca.php', // web UI entry point (require auth.php); not loadable in the isolated unit process 'servcheck_credential.php', // web UI entry point (require auth.php); not loadable in the isolated unit process + 'servcheck_process.php', // CLI/daemon poller entry point (shebang, chdir + include, pcntl signal handling); not loadable in the isolated unit process 'servcheck_proxy.php', // web UI entry point (require auth.php); not loadable in the isolated unit process 'servcheck_restapi.php', // web UI entry point (require auth.php); not loadable in the isolated unit process 'servcheck_test.php', // web UI entry point (require auth.php); not loadable in the isolated unit process