Repository navigation
Relocate schema into includes/database.php - #61
Merged
Merged
Conversation
- Move hmib_setup_table() verbatim into includes/database.php, loaded once via a top-level require_once in setup.php. - Measure includes/database.php and repoint the index-guard source scan at its new location. Keeps the raw CREATE TABLE definitions as-is (lighter relocation).
TheWitness
requested review from
bmfmancini,
browniebraun,
cigamit and
xmacan
and
a balanced review from Copilot
September 30, 2026 13:14
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The relocated schema conflicts with mandatory schema API, header, PHPDoc, and changelog conventions.
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Relocates Host MIB schema provisioning into the fleet-standard database include while preserving behavior.
Changes:
- Moves
hmib_setup_table()intoincludes/database.php. - Loads the schema include from
setup.php. - Updates coverage configuration and the index-guard test path.
| File | Description |
|---|---|
includes/database.php |
Contains relocated schema provisioning. |
setup.php |
Loads the database include. |
phpunit.xml |
Adds the include to coverage sources. |
tests/Security/IndexGuardConsistencyTest.php |
Scans the relocated function. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Restores the warranty disclaimer and Cacti Group maintainer lines that the abbreviated header omitted, matching setup.php and the other PHP files in the repository.
Adds a develop-section entry for moving schema provisioning into includes/database.php and introducing the manifest.json file-pruning mechanism.
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 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.
The trailing '# ...' comments in the Project Structure block drifted further right down the tree; align them all to a single column.
- 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.
cigamit
approved these changes
Oct 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Relocate schema into includes/database.php and add the fleet file manifest
Aligns
plugin_hmibwith the fleet schema/includes convention and adds the fleet-widemanifest.json+ upgrade-time file-pruning mechanism.includes/database.php, loaded via a top-levelrequire_onceinsetup.php(behavior unchanged).manifest.jsonwithtombstones(empty — this relocation moved a function, not files),expected(top-level files/directories shipping today, directories with a trailing/), andwhitelist(empty).hmib_prune_files()(insetup.php, called from the version-change block ofhmib_check_upgrade()) removes the dev-onlytests/tree on upgrade, refuses any path that resolves outside the plugin directory (a tamperedmanifest.json), warns on any file/directory it cannot remove, leaveswhitelist/.git*alone, and logs — without removing — any top-level entry the manifest does not account for.tests/bin/validate-manifest.php(wired intoplugin-ci-workflow.yml) fails on drift betweenexpectedand the real top-level tree.PruneFilesTest(tombstone/file/dir removal, path-escape refusal, permission warnings, whitelist/.gitprotection, missing/malformed no-ops); sandboxedbase_pathinHmibLifecycleTest(beforeEach/afterEach) so its upgrade-path tests run the prune against a throwaway tree.Validation
Full Pest suite green (33 passed) and patch-coverage passes at 100% (102/102 changed lines); manifest drift-check passes and the translation template is up to date.
Revision: hardening & fleet cleanup
Since the initial description, this PR also:
phpunit.xmlon upgrade (alongside the dev-onlytests/tree) and leaves.md*lint configs in place — the drift check now ignorestests/,phpunit.xml,.git*,.md*, and whitelisted paths../..traversal segment or resolves outside the plugin directory (including via a symlinked directory), and protects a directory when a whitelisted entry lives beneath it — each with added unit coverage.hmib_prune_files()/hmib_rmtree()(theplugin_hmib_prefix is reserved for lifecycle/hook-registration functions).tests/Unit/PruneFilesTest.phpthe full standard GPL v2 header and aligns the Project Structure block in.github/copilot-instructions.md.