Skip to content

Feature-detect Cacti 1.3 instead of CACTI_VERSION in audit_utilities_array - #93

Merged
TheWitness merged 3 commits into
developfrom
fix/utilities-array-version-gate
Oct 8, 2026
Merged

TheWitness merged 3 commits into
developfrom
fix/utilities-array-version-gate

Conversation

@TheWitness

@TheWitness TheWitness commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Problem

audit_utilities_array() (the utilities_array hook, which adds a "View Audit
Log" entry under Technical Support on the Utilities page) gates on a version
string:

if (version_compare(CACTI_VERSION, '1.3.0', '<')) {
    ...
}

On 1.3 the Audit Log link is surfaced through config_arrays instead. But
current develop builds still report a version that compares < 1.3.0, so on
those builds this legacy block runs as well — adding the entry a second time,
and, if core no longer pre-populates the legacy $utilities['Technical Support']
section, running array_merge() against an unset key (TypeError).

Same unreliable CACTI_VERSION gating recently fixed in plugin_monitor (#270)
and plugin_flowview.

Fix

Detect Cacti 1.3 by a class it introduced (CactiTableFilter) rather than the
version string — the same signal used in the monitor fix — and leave the
string-bearing body untouched:

if (!class_exists('CactiTableFilter')) {
    if (api_plugin_user_realm_auth('audit.php')) {
        ...
    }
}
  • True legacy Cacti (< 1.3, no CactiTableFilter): the entry is added exactly
    as before.
  • Cacti 1.3+ and any develop build reporting < 1.3.0: the block is skipped, so
    the entry is never doubled and the array_merge() never runs on an unset key.

Only the gate line changes; the translatable strings are unchanged, so the i18n
template check stays green.

Testing

  • php -l setup.php — no syntax errors.
  • php tests/bin/check-i18n-pot.php <base> — exit 0 (no translatable-string
    changes).

@TheWitness
TheWitness requested review from bmfmancini and xmacan and a balanced review from Copilot October 8, 2026 18:55

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.

🟡 Changes recommended

The guard does not distinguish the menu implementations on develop, and required behavioral coverage is missing.

2 open findings
What changed in this PR

Updates the audit plugin’s Utilities hook to inspect the menu structure rather than rely on Cacti’s version string.

Changes:

  • Guard against a missing Technical Support section before merging the audit entry.
  • Update the hook documentation and changelog.
File Description
setup.php Replaces the version gate with a section-existence check.
CHANGELOG.md Documents the intended 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.

Comment thread setup.php Outdated
Comment thread setup.php Outdated
@TheWitness
TheWitness force-pushed the fix/utilities-array-version-gate branch 2 times, most recently from 0f1a364 to c2e3324 Compare October 8, 2026 19:04
@TheWitness TheWitness changed the title Feature-detect legacy Utilities section instead of CACTI_VERSION gate Feature-detect Cacti 1.3 instead of CACTI_VERSION in audit_utilities_array Oct 8, 2026
@TheWitness
TheWitness force-pushed the fix/utilities-array-version-gate branch 3 times, most recently from 692daf4 to 06ebb05 Compare October 8, 2026 19:18
…array

audit_utilities_array() gated its Utilities-page entry on version_compare(CACTI_VERSION,'1.3.0','<'). A develop build can report < 1.3.0 while surfacing the Audit Log link via config_arrays, so the legacy block also ran: the entry was doubled and array_merge() could run against an unset Technical Support key. Detect 1.3 via class_exists('CactiTableFilter') instead and leave the translatable strings unchanged.
@TheWitness
TheWitness force-pushed the fix/utilities-array-version-gate branch from 06ebb05 to 86bc3ed Compare October 8, 2026 19:18
xmacan
xmacan previously approved these changes Oct 8, 2026
…s branches

Guard the legacy array_merge() with a null-coalesce so the Utilities hook never runs against an unset Technical Support section (missing-key protection), and replace the single placeholder test with focused coverage for the absent-section, populated-section-with-access, and access-denied paths.
…ches develop

The CI i18n check compares every __() call occurrence, not just unique strings. Extracting the section into a single \ variable dropped __('Technical Support', 'audit') from two calls to one, tripping the pot-sync gate even though the unique-string set is unchanged. Apply the missing-key null-coalesce in place instead.
@TheWitness
TheWitness merged commit af017dd into develop Oct 8, 2026
5 checks passed
@TheWitness
TheWitness deleted the fix/utilities-array-version-gate branch October 8, 2026 19:46
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