Repository navigation
Gate pre-1.3 report shims on Cacti version to stop redeclare on 1.3.0 develop - #289
Merged
Merged
Conversation
TheWitness
requested review from
bmfmancini and
xmacan
and
a balanced review from Copilot
October 9, 2026 20:41
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The newly introduced version-gated paths lack direct regression coverage.
1 open finding
What changed in this PR
Updates report-shim loading to avoid function redeclaration on Cacti 1.3.
Changes:
- Gates compatibility shims using the Cacti version.
- Retains a standalone fallback and updates the changelog.
| File | Description |
|---|---|
includes/functions.php |
Adds version-based shim gating. |
CHANGELOG.md |
Documents the fix. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ReportsShimGuardTest
cigamit
approved these changes
Oct 9, 2026
bmfmancini
approved these changes
Oct 9, 2026
bmfmancini
approved these changes
Oct 9, 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 a Cacti 1.3.0 develop build, loading a page/poller that pulls in core's report library fatally errors:
reports_run()/reports_queue()/reports_log_and_notify()became native in Cacti 1.3. The plugin'sincludes/functions.phpgated its pre-1.3 shims (includes/functions-pre13.php) behind!function_exists('reports_run'). Butfunctions.phpis included during plugin init before core loadslib/reports.php, so the probe runs while the now-native helpers are still absent, declares the shims, and core then fatally redeclares them whenlib/reports.phpis finally included. Afunction_exists()check can't win a load-order race.Fix
Gate the shims on the Cacti version, which is fixed at bootstrap and independent of include order:
cacti_version_compare()treats a1.3.0develop build (CACTI_VERSIONresolves to'1.3.0') as>= 1.3, so the shims are loaded only on genuinely older releases (the plugin still declarescompat = 1.2.29). Thefunction_exists()fallback is retained for the one case the Cacti version helpers aren't available — includingfunctions.phpoutside a full Cacti bootstrap, astests/Unit/ReportsShimGuardTest.phpdoes.Validation
php -l includes/functions.php— clean.functions.php:CACTI_VERSION=1.3.0): shim not loaded → core provides the natives, no redeclare.functions-pre13.php(still required there).function_exists(), shim not loaded, no redeclare —ReportsShimGuardTeststays green.