Skip to content

Fix incorrect maint functions include path - #96

Merged
TheWitness merged 1 commit into
developfrom
fix_maint_include
Oct 15, 2026
Merged

TheWitness merged 1 commit into
developfrom
fix_maint_include

Conversation

@TheWitness

Copy link
Copy Markdown
Member

Problem

The maint plugin relocated functions.php into its includes/ subdirectory (plugins/maint/includes/functions.php); the old top-level plugins/maint/functions.php no longer exists. webseer_process.php still does:

if (api_plugin_is_enabled('maint')) {
    require_once($config['base_path'] . '/plugins/maint/functions.php');
}

With the maint plugin enabled, that require_once on a now-missing file throws a fatal error and aborts the URL check in the poller process.

Fix

Probe for the relocated includes/functions.php first, fall back to the legacy top-level path for older maint installs, and log an error instead of fataling if neither is present:

if (api_plugin_is_enabled('maint')) {
    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, 'WEBSEER');
    }
}

The downstream plugin_maint_check_webseer_url() call is already guarded by function_exists(), so a missing maint include now degrades gracefully instead of crashing the poller.

Notes

  • This is the same class of bug fixed for plugin_servcheck (PR #134). A deliberate anti-pattern to avoid is file_exists(require_once(...)), which evaluates require_once inside the file_exists() argument (including the file as a side effect, or fataling when it is absent).
  • No patch-coverage allowlist change is needed: webseer_process.php is already listed as a CLI/daemon entry point in tests/bin/patch-coverage.php.
  • php -l passes on the changed file.

The maint plugin relocated functions.php to includes/functions.php, so the
old require_once(plugins/maint/functions.php) now fatals with a missing
file whenever the maint plugin is enabled.

Probe for the relocated includes/functions.php first and fall back to the
legacy top-level path, logging an error if neither exists instead of
fataling. The downstream plugin_maint_check_webseer_url() call is already
guarded by function_exists(), so a missing include degrades gracefully.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 15, 2026 13:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The narrow fix preserves legacy compatibility and the guarded maintenance check, with no unresolved findings.

0 open findings

What changed in this PR

Fixes maintenance-plugin loading so relocated helper files no longer abort Webseer poller checks.

Changes:

  • Prefer the new includes/functions.php location, with legacy fallback.
  • Log an error when neither file exists instead of attempting a missing-file include.
File Description
webseer_process.php Adds compatible maintenance-helper loading and missing-file handling.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@TheWitness
TheWitness merged commit 84d49d4 into develop Oct 15, 2026
4 checks passed
@TheWitness
TheWitness deleted the fix_maint_include branch October 20, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants