From 53ecb6c5004d5454633228ffe40b512fab63f3e5 Mon Sep 17 00:00:00 2001 From: Copilot Date: Tue, 29 Sep 2026 21:39:26 -0400 Subject: [PATCH 01/12] Use require/require_once for all file inclusions Switches every include/include_once to require/require_once for fail-fast consistency. Schema already lives in includes/setup/database.php via api_plugin_db_table_create()/gpsmap_upgrade_database(), and the library code is already under includes/, so no schema or file-move changes were needed. --- .github/copilot-instructions.md | 6 +++++- CHANGELOG.md | 1 + gpsmap.php | 10 +++++----- gpstemplates.php | 4 ++-- includes/polling.php | 4 ++-- includes/polling/functions.php | 4 ++-- includes/polling/kmlcreation.php | 2 +- includes/polling/processregion.php | 2 +- includes/setup/database.php | 5 +++-- setup.php | 4 ++-- 10 files changed, 24 insertions(+), 18 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 07a9305..c035145 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -134,7 +134,7 @@ function gpsmap_check_upgrade() { $old = read_config_option('plugin_gpsmap_version', TRUE); if ($current != $old) { - include_once($config['base_path'] . '/plugins/gpsmap/includes/setup/database.php'); + require_once($config['base_path'] . '/plugins/gpsmap/includes/setup/database.php'); gpsmap_upgrade_database(); } } @@ -244,6 +244,10 @@ existing code or adding new code, not just in dedicated cleanup passes: - **i18n text domain.** Every `__()`/`__esc()` call must include this plugin's text domain as the final argument, except when deliberately comparing against a literal, untranslated Cacti-core label. +- **File inclusion uses `require`/`require_once`.** Always use `require`/`require_once` (never + `include`/`include_once`) so a missing dependency fails fast and loudly. This plugin already keeps + its library/helper code under `includes/` (schema in `includes/setup/database.php`); reference + plugin files from there. - **Plugin table-creation API.** Use `api_plugin_db_table_create()`/`api_plugin_db_add_column()` (from Cacti core's `lib/plugins.php`) instead of raw `CREATE TABLE`/`ALTER TABLE ... ADD COLUMN`. Both are idempotent (safe no-ops when already applied), so the same call can run unconditionally diff --git a/CHANGELOG.md b/CHANGELOG.md index b997f1e..938ad88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## Changelog --- develop --- +* refactor: Switch every file inclusion from include/include_once to require/require_once for fail-fast consistency (schema already lives in includes/setup/database.php via the plugin table API, so no schema changes were needed) * dev: Enforce patch coverage of changed lines in CI and remove the inert COMPOSER_ROOT_VERSION env from the Pest step * security: Add a version-safe CSP nonce (`plugin_gpsmap_csp_nonce()`) to every inline `