From d8eaeb9e7a9a06545375b2aae9706d68039fb81d Mon Sep 17 00:00:00 2001 From: TheWitness Date: Thu, 8 Oct 2026 14:50:38 -0400 Subject: [PATCH] bug: pass bool (not int) to api_plugin_register_hook() enable argument Cacti 1.3 types api_plugin_register_hook() 5th arg as bool enable. These calls passed int 1, which only coerces while the file lacks declare(strict_types=1); pass true so they stay type-correct. php -l clean. --- CHANGELOG.md | 1 + setup.php | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a468a1..c3c3172 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ --- develop --- +* bug: Pass a boolean (not the integer 1) to api_plugin_register_hook()'s $enable argument so the hook registration stays type-correct under Cacti 1.3's strict bool type-hint (the int only coerces while the file lacks declare(strict_types=1)) * bug: Skip audit logging on CLI/poller requests until the `request_status` column exists, instead of emitting "Unknown column 'request_status'" errors when the audit_log schema migration (which only runs on plugins.php/audit.php page loads) has not yet applied; likewise make the shutdown-time request finalizer (`audit_finalize_request()`), which writes `request_status`, best-effort (its writes pass `$log = false`) so it fails quietly instead of logging "Table 'audit_log' doesn't exist" when the table was dropped (e.g. plugin uninstall) after `db_table_exists()`'s request-scoped cache was primed * dev: Enforce patch coverage of changed lines in CI and remove the inert COMPOSER_ROOT_VERSION env from the Pest step * dev: Relocate the schema/DB provisioning helpers (`audit_setup_table()`, `audit_setup_syslog_table()`, `audit_setup_user_log_state_table()`, `audit_upgrade_event_schema()`, and the user_log index helpers) from `setup.php` into `includes/database.php` to align with the fleet schema/includes convention, and add a root `manifest.json` with upgrade-time file pruning (`audit_prune_files()`) plus a CI manifest drift check (`tests/bin/validate-manifest.php`) diff --git a/setup.php b/setup.php index 60aa0aa..334676d 100644 --- a/setup.php +++ b/setup.php @@ -402,11 +402,11 @@ function audit_check_upgrade(): void { [$info['version'], $info['longname'], $info['author'], $info['homepage'], $info['name']]); // hook for table replication - api_plugin_register_hook('audit', 'replicate_out', 'audit_replicate_out', 'setup.php', 1); - api_plugin_register_hook('audit', 'is_console_page', 'audit_is_console_page', 'setup.php', 1); - api_plugin_register_hook('audit', 'logout_pre_session_destroy', 'audit_logout_pre_session_destroy', 'setup.php', 1); - api_plugin_register_hook('audit', 'logout_post_session_destroy', 'audit_logout_post_session_destroy', 'includes/functions.php', 1); - api_plugin_register_hook('audit', 'custom_denied', 'audit_custom_denied', 'includes/functions.php', 1); + api_plugin_register_hook('audit', 'replicate_out', 'audit_replicate_out', 'setup.php', true); + api_plugin_register_hook('audit', 'is_console_page', 'audit_is_console_page', 'setup.php', true); + api_plugin_register_hook('audit', 'logout_pre_session_destroy', 'audit_logout_pre_session_destroy', 'setup.php', true); + api_plugin_register_hook('audit', 'logout_post_session_destroy', 'audit_logout_post_session_destroy', 'includes/functions.php', true); + api_plugin_register_hook('audit', 'custom_denied', 'audit_custom_denied', 'includes/functions.php', true); } }