diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 0033eb3..d2150fc 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -29,7 +29,7 @@ slowlog/ # Repository root (install to plugins/slowlog/ in ├── images/ # UI icons ├── includes/ # Library/helper files, require_once'd from the entry points │ ├── database.php # Schema management: table defs + create/upgrade/drop helpers -│ └── slowlog_functions.php # Log parsing, import, and charting logic +│ └── functions.php # Log parsing, import, and charting logic ├── js/ # Chart rendering client-side code ├── locales/ # Internationalization files ├── tests/ # Test suite @@ -207,7 +207,7 @@ existing code or adding new code, not just in dedicated cleanup passes: label. - **File inclusion uses `require`/`require_once`.** Always use `require`/`require_once` (never `include`/`include_once`) so a missing dependency fails fast and loudly. Keep library/helper files - (e.g. `slowlog_functions.php`, `includes/database.php`) under `includes/` and reference them from + (e.g. `functions.php`, `includes/database.php`) under `includes/` and reference them from that path; entry points (`slowlog.php`, `import_log.php`, `setup.php`) stay in the plugin root. - **Plugin schema management.** Keep every schema function (table definitions, create, upgrade, drop) in `includes/database.php` (the thold model), included from `setup.php`'s install/upgrade diff --git a/CHANGELOG.md b/CHANGELOG.md index f90b782..664cd95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ * refactor: De-normalize the per-query method classification - `plugin_slowlog_details_methods` now stores the method name directly in a `method` varchar column instead of a `methodid` foreign key into `plugin_slowlog_methods`, and the classifier fragment dictionary moved into a PHP constant (`SLOWLOG_METHOD_FRAGMENTS`). The stats, By Method chart, details list, method filter dropdown, and chart-scope queries no longer join `plugin_slowlog_methods`, removing a join from every one of those read paths. The now-unused `plugin_slowlog_methods` dictionary table is left in place (a clean install drops it) * bug: Migrate an existing `plugin_slowlog_details_methods` table in place during upgrade - `api_plugin_db_table_create()` never retrofits a table that already exists, so on an existing install the de-normalization above would otherwise leave the old `methodid` column (and no `method` column), breaking every import/detail/stat/chart query with an unknown-column error. `slowlog_check_upgrade()` now runs an idempotent `slowlog_migrate_details_methods_to_method()` that adds the `method` column, backfills the names from the `plugin_slowlog_methods` dictionary, then swaps the primary key to `(logid, logentry, method)` and drops `methodid`. It runs on every page (self-gating on the `methodid` column) because this schema change ships without a version bump, so the version-drift upgrade branch would never fire for it * refactor: Move the slowlog_functions.php library file into includes/ and switch every file inclusion from include/include_once to require/require_once for fail-fast consistency (references updated across setup.php, slowlog.php, import_log.php, and the test suite) +* refactor: Rename includes/slowlog_functions.php to includes/functions.php to match the Cacti plugin naming convention; every require/loadPluginSource reference and the Pest coverage source list were updated, and a manifest.json tombstone (includes/slowlog_functions.php) prunes the old filename from existing installs on upgrade * refactor: Move all schema management (table definitions, create, upgrade, and drop helpers) into includes/database.php (the thold model) with the Cacti copyright header; setup.php's install/uninstall/upgrade paths now require that file and delegate to it, keeping the api_plugin_db_table_create() create path and the db_update_table() upgrade refresh unchanged * dev: Enforce patch coverage of changed lines in CI and remove the inert COMPOSER_ROOT_VERSION env from the Pest step * bug: Fix the By Method/By Table chart scope filter rendering two overlapping widgets (a select2 multi-select and the jQuery multiselect) with an overlapping search box - `slowlog_charts_filter()` unconditionally applied `.multiselect()` to `#chart_scope` while Cacti core independently turned the same plain `