Repository navigation
Fix fatal redeclare from leftover legacy include/ directory - #415
Merged
Merged
Conversation
TheWitness
requested review from
bmfmancini and
xmacan
and
a balanced review from Copilot
October 6, 2026 17:18
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Cleanup can miss stale hooks and follow a symlink outside the plugin directory, and the recovery behavior lacks tests.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Adds early cleanup for legacy include/ installations to prevent fatal function redeclarations.
Changes:
- Repoints stale plugin hook paths.
- Removes the legacy directory before later hooks execute.
- Documents the fix in the changelog.
| File | Description |
|---|---|
setup.php |
Adds and invokes legacy-directory cleanup. |
CHANGELOG.md |
Records the upgrade fix. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
xmacan
previously approved these changes
Oct 6, 2026
xmacan
approved these changes
Oct 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
On installs upgraded from the old layout, the plugin fatals and Cacti auto-disables it:
The library directory moved from
include/toincludes/. After an upgrade, the oldinclude/directory lingers on disk and staleplugin_hooksrows still point atinclude/<file>. When a stale hook (e.g.graph_buttons) fires, Cacti loadsinclude/functions.php; the plugin's own code then loadsincludes/functions.php, redeclaring every shared function → fatal.The existing repoint + prune logic lives inside
intropage_upgrade_database(), which runs fromdisplay_information()/ the config-check hook — too late: the stale hook fires earlier in the same request, and once Cacti disables the plugin the migration never runs again, so the install is permanently stuck.Fix
Add
intropage_cleanup_legacy_include()and call it at the top ofintropage_config_arrays()— the earliest per-page hook, always registered fromsetup.php(a file that was never underinclude/, so its hook row is never stale). Before any stalegraph_buttons/console_afterhook can load the old library, it:plugin_hooksrow frominclude/toincludes/(fixes future requests), andinclude/directory (so a hook target cached for the current request can no longer load a second copy of the library).It early-returns when
include/is absent, so it's a cheapis_dir()no-op on healthy installs. Reuses the existingplugin_intropage_rmtree()helper and logs a warning if removal is blocked by permissions.Testing
php -l setup.phppasses.