diff --git a/CHANGELOG.md b/CHANGELOG.md index 50a4ee8..5ba19b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ --- develop --- +* bug: Guard the pre-1.3 report compatibility shims (reports_run/reports_queue/reports_log_and_notify) behind a function_exists() check instead of a CACTI_VERSION string comparison, so a develop build that reports a version comparing < 1.3 no longer fatally redeclares those now-native functions * security: Move the plugin's remaining inline event handlers to CSP-safe bindings so the pages no longer trip Cacti's Content-Security-Policy script-src-attr directive: confirmation Cancel buttons use the `cactiReturnTo` class, the database/filter selects are bound via change() in their ready blocks, and the main filter's sort/report selects and time-shift icons are bound in flowview_display_filter's ready block * dev: Replace the translation-template CI check that regenerated locales/po/cacti.pot and compared it with a diff-based gate (tests/bin/check-i18n-pot.php) requiring cacti.pot to be updated only when a pull request adds, removes, or modifies an i18n function call * issue: Prevent flow-capture from fatally erroring (TypeError in spl_object_hash) when flowview_db_check_reconnect() held a null shared-database handle; normalize a non-object connection to false so db_check_reconnect() checks and reconnects the default connection instead diff --git a/includes/functions.php b/includes/functions.php index 9c41102..55a1850 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -23,7 +23,11 @@ +-------------------------------------------------------------------------+ */ -if (version_compare(CACTI_VERSION, '1.3', '<')) { +// reports_run()/reports_queue()/reports_log_and_notify() are native in Cacti +// 1.3+. Load the compat shims only when they are actually missing: a develop +// build can report a version that compares < 1.3 while already defining them +// natively, and unconditionally including the shims would fatally redeclare them. +if (!function_exists('reports_run')) { require_once(__DIR__ . '/functions-pre13.php'); } diff --git a/tests/Unit/ReportsShimGuardTest.php b/tests/Unit/ReportsShimGuardTest.php new file mode 100644 index 0000000..a24d538 --- /dev/null +++ b/tests/Unit/ReportsShimGuardTest.php @@ -0,0 +1,50 @@ +toBeTrue(); + + $script = <<<'CHILD' +>>'; +CHILD; + + $tmp = tempnam(sys_get_temp_dir(), 'pre13_'); + expect($tmp)->not->toBeFalse(); + + try { + file_put_contents($tmp, $script); + + $command = escapeshellarg(PHP_BINARY) . ' ' . escapeshellarg($tmp) . ' ' . escapeshellarg($functions); + $output = (string) shell_exec($command); + + expect($output)->toContain('<<>>'); + expect($output)->not->toContain('redeclare'); + } finally { + @unlink($tmp); + } +});