Repository navigation
Guard pre-1.3 report shims with function_exists to avoid redeclare fatal - #288
Merged
Merged
Conversation
TheWitness
requested review from
bmfmancini and
xmacan
and
a balanced review from Copilot
October 8, 2026 18:52
functions-pre13.php unconditionally defines reports_run/reports_queue/reports_log_and_notify, which are native in Cacti 1.3. A develop build can report a version comparing < 1.3 while already defining them, so the version_compare gate loaded the shims and fatally redeclared them. Gate on function_exists('reports_run') instead.
TheWitness
force-pushed
the
fix/pre13-reports-shim-redeclare
branch
from
October 8, 2026 18:54
4e8688e to
777b42d
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The develop-only redeclaration scenario lacks targeted regression coverage.
1 open finding
What changed in this PR
Updates report compatibility loading to avoid function redeclaration failures on Cacti develop builds.
Changes:
- Replaces version-based shim loading with a
function_exists()guard. - Documents the fix in the changelog.
| File | Description |
|---|---|
includes/functions.php |
Guards legacy report shims using runtime function availability. |
CHANGELOG.md |
Records the compatibility fix. |
🧠 Review effort: Balanced
💡 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 8, 2026
…elpers Addresses PR review: CI checks out Cacti 1.2.x (report helpers absent) and the bootstrap already loaded functions.php, so the develop-only 'natives present' path is not covered in-process. Add an isolated child-process test that defines reports_run/reports_queue/reports_log_and_notify, requires functions.php, and asserts it loads without a redeclaration.
xmacan
approved these changes
Oct 8, 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
includes/functions.phploads the pre-1.3 report compatibility shims with aversion-string gate:
functions-pre13.phpunconditionally definesreports_run(),reports_queue(), andreports_log_and_notify(). Cacti core defines all threenatively in
lib/reports.phpon 1.3. Currentdevelopbuilds still report aversion that compares
< 1.3, so this block loads the shims even though thenative functions already exist, producing a
Cannot redeclare reports_run()fatal on flowview's report pages and the report poller.
This is the same unreliable
CACTI_VERSIONgating that was just fixed inplugin_monitor(#270); here it surfaces as a hard fatal rather than a UI hang.Fix
Gate on the actual presence of the functions rather than the version string.
Core adds all three together, so checking the representative
reports_run()issufficient:
< 1.3while already definingthe functions natively: shims are skipped, no redeclare.
functions-pre13.phpis loaded only from this one site (verified), so no otherinclude path can trip the redeclare.
Testing
php -l includes/functions.php— no syntax errors.