Skip to content

Relocate theme CSS to css/ and keywords to docs/, add the file manifest + upgrade prune (compat 1.2.29) - #46

Merged
cigamit merged 11 commits into
mainfrom
chore/compat-1.2.29
Oct 1, 2026
Merged

cigamit merged 11 commits into
mainfrom
chore/compat-1.2.29

Conversation

@TheWitness

@TheWitness TheWitness commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Summary

Brings plugin_slowlog in line with the fleet-wide conventions:

  • File relocations — moves the per-theme chart stylesheet and the parser keyword list into their conventional directories.
  • File manifest + upgrade-time pruning — adds the fleet manifest.json and prune mechanism, with drift enforcement wired into CI.
  • Compatibility — sets the INFO compat floor to 1.2.29.

File relocations (recorded as manifest tombstones)

  • themes/ → css/ (flattened) — themes/modern/apexcharts.css is relocated to css/modern_apexcharts.css (git mv, history preserved) using a flat, theme-prefixed filename; the four themes/$selected_theme/apexcharts.css references in slowlog.php are repointed to css/{$selected_theme}_apexcharts.css. The retired themes/ directory is tombstoned.
  • keywords.txt → docs/keywords.txt — the SQL reserved-word list used by the parser moves under docs/; the old top-level path is tombstoned.

File manifest + upgrade-time pruning

  • New root manifest.json: tombstones = ["keywords.txt", "themes/"], expected (the current top-level tree; directories carry a trailing /), and whitelist (empty — no user-writable runtime tree).
  • slowlog_prune_files() (in setup.php, called from the version-change branch of slowlog_check_upgrade() after slowlog_upgrade_tables()) removes the tombstoned paths, the dev-only tests/ tree, and phpunit.xml on upgrade; leaves whitelist, .git*, and .md* files in place; and logs — without removing — any unaccounted top-level entry.
  • Tamper-hardened: refuses any tombstone whose normalized path contains a ./.. traversal segment or resolves outside the plugin directory (including via a symlinked directory), and protects a directory when a whitelisted entry lives beneath it. Warns in the Cacti log on anything it cannot remove.
  • tests/bin/validate-manifest.php (wired into plugin-ci-workflow.yml) fails on drift between expected and the real top-level tree (it ignores tests/, phpunit.xml, .git*, .md*, and whitelisted paths).

Compatibility

  • INFO compat floor set to 1.2.29 (the proposed 1.2.32 floor was not adopted).
  • Unique-key assessment — this plugin is not affected by the Cacti 1.2.29–1.2.31 db_update_table() unique-key drop: its db_update_table() call targets plugin_slowlog_details (which declares no unique key), while its only unique_keys-declared index (plugin_slowlog_table_names.table_name) is never passed through db_update_table(). No re-introduction helper is required.

Docs & tests

  • Added tests/Unit/PruneFilesTest.php (tombstone/tests//phpunit.xml removal, whitelist & .git protection, traversal-segment and symlink-escape refusal, whitelist-ancestor protection), using the full standard GPL v2 header.
  • SlowlogCheckUpgradeTest sandboxes base_path (a temp tree with a copy of INFO, an empty includes/database.php, and no manifest) for its drift cases so the prune is a no-op there while the new call line stays covered.
  • Aligned the Project Structure block in .github/copilot-instructions.md to the new layout.

Validation

php -l clean on all changed PHP files; full Pest suite green and patch-coverage passes at 100% of changed measured lines; manifest drift-check passes and the translation template is up to date.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Compatibility documentation and the changelog must be synchronized with the new support floor.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
What changed in this PR

Lowers the minimum supported Cacti version from 1.2.32 to 1.2.29.

Changes:

  • Updates the plugin compatibility floor.
File Description
INFO Changes minimum Cacti compatibility to 1.2.29.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread INFO
Copilot added 3 commits September 30, 2026 16:04
phpunit.xml ships in the repo for CI but is a dev-only test artifact, so it
is removed from manifest.json 'expected', pruned from installs on upgrade
(like tests/), and excluded from the manifest drift check.

The retired markdown-lint configs (.mdlrc, .md_style.rb) are deleted, and
.md* is now ignored like .git*: protected from pruning and excluded from
drift if it reappears.
The reserved-words seed file moves to docs/; includes/database.php loads it
from the new path during table setup, and it is tombstoned so existing
installs drop the stale top-level copy on upgrade.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Theme CSS paths are broken, and crafted tombstones can bypass pruning safeguards and delete protected content.

Review effort: Balanced
Findings: 1 High severity · 2 Medium severity

Open (3)
Resolved since last review (1)

Comment thread setup.php
Comment thread slowlog.php Outdated
Comment thread slowlog.php Outdated
Copilot added 7 commits September 30, 2026 22:17
The upgrade-time prune now rejects any tombstone containing '.'/'..' segments
(which could escape the plugin directory or resolve to its root) and treats
ancestors of whitelist entries as protected, so a tombstone on a parent
directory can no longer delete a whitelisted file beneath it.
Point the structure tree at the relocated files (libraries now under
includes/, data files under docs/, stylesheets under css/) and align the
trailing '# ...' comments to a single column so they no longer drift right.
The themes/ -> css/ flatten dropped the $selected_theme directory segment,
producing "plugins/slowlog/css//apexcharts.css", which never resolves the
relocated css/modern/apexcharts.css. Both the import and chart views
therefore always fell back to the generic stylesheet. Reference
css/$selected_theme/apexcharts.css to match the new layout.
- Use the full license header (from the plugin's own setup.php) in
  tests/Unit/PruneFilesTest.php instead of the abbreviated copyright banner.
- Document that the manifest drift check and the upgrade-time prune also
  handle phpunit.xml and .md* files, matching the implemented behavior.
The repository naming contract reserves the plugin_<name>_ prefix for plugin
lifecycle / hook-registration functions; all other functions use the plain
<name>_ prefix. Rename the internal upgrade helpers accordingly:

  plugin_<name>_prune_files() -> <name>_prune_files()
  plugin_<name>_rmtree()      -> <name>_rmtree()

The call site, unit tests, and the copilot-instructions.md references are
updated to match. No behavioral change.
Align the compat metadata (and the contributor-guide references) with the
team decision to standardize the minimum supported Cacti version at 1.2.29;
the previously proposed 1.2.32 floor was not adopted.
Replace the per-theme css/<theme>/apexcharts.css subdirectory layout with a
flat css/<theme>_apexcharts.css naming scheme (e.g. css/modern_apexcharts.css),
repointing both the import and chart views at
css/{$selected_theme}_apexcharts.css.
@TheWitness TheWitness changed the title INFO: back off compat to 1.2.29 Relocate theme CSS to css/ and keywords to docs/, add the file manifest + upgrade prune (compat 1.2.29) Oct 1, 2026
@cigamit
cigamit merged commit ebf1aa7 into main Oct 1, 2026
5 checks passed
@cigamit
cigamit deleted the chore/compat-1.2.29 branch October 1, 2026 06:39
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