Skip to content

Chore/extract setup modules - #388

Merged
TheWitness merged 8 commits into
developfrom
chore/extract-setup-modules
Oct 7, 2026
Merged

TheWitness merged 8 commits into
developfrom
chore/extract-setup-modules

Conversation

@bmfmancini

@bmfmancini bmfmancini commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

This pull request refactors the Syslog plugin's setup and module structure, clarifies documentation, and introduces new logic to enforce storage engine compatibility when Remote Data Collector options are enabled. The changes aim to modularize the codebase, improve maintainability, and ensure correct storage engine selection during installation and configuration.

Key highlights:

  • The setup and core logic are now modularized, with clear boundaries and documentation for each module.
  • New helper functions enforce the use of the InnoDB storage engine when any Remote Data Collector feature is enabled.
  • Documentation has been updated throughout to reflect the new structure and logic, including developer guidance and changelog entries.

Most important changes:

1. Setup and Module Structure Refactor

  • Modularized the plugin by moving shared libraries to includes/, defining clear ownership for setup, schema, processing, settings, navigation, installer, and utilities modules. Updated documentation and developer instructions to reflect these boundaries. (.github/copilot-instructions.md, docs/setup-modules.md) [1] [2] [3]
  • Updated hook registration and callback documentation to reference the correct owning modules, ensuring each hook is registered and loaded from its appropriate file.

2. Storage Engine Enforcement for Remote Data Collector

  • Added new functions syslog_remote_collector_requires_innodb, syslog_install_storage_engine, and syslog_install_storage_engine_is_compatible in includes/functions.php to require InnoDB when any Remote Data Collector option is enabled, logging a warning and overriding incompatible selections.
  • Updated user and developer documentation (README.md, .github/copilot-instructions.md) to clarify that enabling any Remote Data Collector option mandates InnoDB and that the setup advisor will enforce this automatically. [1] [2]

3. Documentation and Changelog Updates

  • Expanded and clarified documentation, including the README, developer instructions, and a new docs/setup-modules.md file, to explain the new module boundaries, hook ownership, and test rules. [1] [2] [3]
  • Added changelog entries for the new features, refactoring, and CI/dependency baseline changes.

4. Code Cleanup

  • Removed the unused syslog_check_changed function from includes/functions.php as part of ongoing code cleanup.

5. Miscellaneous Improvements

  • Updated file references in documentation to reflect the new module paths, such as moving database.php and functions.php under includes/. [1] [2]

These changes collectively enhance the plugin's maintainability, enforce correct storage engine usage, and provide clear guidance for both users and future contributors.

Copilot AI balanced review requested due to automatic review settings October 6, 2026 22:15
@bmfmancini
bmfmancini force-pushed the chore/extract-setup-modules branch from 45f5b3e to a0ed10f Compare October 6, 2026 22:17

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

MySQL-incompatible schema definitions and replication correctness issues can prevent installation or compromise reliable delivery.

Review effort: Balanced
Findings: 3 High severity · 1 Medium severity · 1 Low severity

Open (5)
What changed in this PR

Refactors setup.php into focused modules while adding remote collector replication, recovery, schema updates, and supporting tests.

Changes:

  • Extracts setup responsibilities into schema, processing, settings, navigation, installer, and utility modules.
  • Adds durable remote replication, recovery workers, telemetry, and transactional failure handling.
  • Updates schemas, documentation, translations, entry points, and regression coverage.
File Description
.github/​copilot-instructions.md Documents module ownership.
AGENTS.md Adds graphify guidance.
CHANGELOG.md Records new features and schema changes.
INFO Bumps version to 4.6.
README.md Documents storage and replication configuration.
config.php.dist Adds Main Collector connection options.
config_local.php.dist Adds remote delivery connection options.
docs/​setup-modules.md Defines setup module boundaries.
includes/​functions.php Implements replication, recovery, and transfer handling.
includes/​installer.php Extracts installer UI and engine validation.
includes/​navigation.php Extracts navigation callbacks.
includes/​processing.php Extracts poller and rule-replication callbacks.
includes/​schema.php Extracts schema logic and adds replication tables.
includes/​settings.php Extracts settings and permission configuration.
includes/​utilities.php Extracts utility callbacks.
lib/​syslog_dashboard.php Removes an unused height helper.
locales/​po/​cacti.pot Updates translation strings and source paths.
syslog.php Adds replication status and stable query projections.
syslog_alerts.php Uses the setup compatibility bootstrap.
syslog_batch_transfer.php Uses the setup compatibility bootstrap.
syslog_counter.php Adds setup bootstrap and connection validation.
syslog_device_rules.php Uses setup bootstrap and normalizes query failure.
syslog_process.php Propagates worker failures and drives replication.
syslog_recovery.php Adds the bounded recovery CLI worker.
syslog_removal.php Uses the setup compatibility bootstrap.
syslog_reports.php Uses the setup compatibility bootstrap.
tests/​bootstrap-unit.php Restores test globals and maps function ownership.
tests/​bin/​patch-coverage.php Includes the recovery worker in coverage.
tests/​regression/​panel_resize_test.php Updates dashboard helper expectations.
tests/​regression/​rule_realm_upgrade_test.php Expands realm migration coverage.
tests/​Security/​CsrfPurgeTest.php Stages extracted modules in its sandbox.
tests/​Security/​IncludePathNormalizationTest.php Verifies setup-based entry-point loading.
tests/​Security/​ItemShareVisibilityTest.php Tests share-table repair.
tests/​Security/​LogicalMessageSearchTest.php Checks stable UNION projections.
tests/​Security/​RemoteCollectorInstallOptionsTest.php Tests remote-option engine constraints.
tests/​Security/​TraditionalTableDeprecationTest.php Uses function-owner source lookup.
tests/​Unit/​CollectorHealthTest.php Updates extracted helper coverage.
tests/​Unit/​DeviceRulePolicyTest.php Tests device-rule creation and replication.
tests/​Unit/​MessageColumnTextTest.php Tests message-column migration.
tests/​Unit/​PartitionPrecreateBoundaryTest.php Uses centralized source ownership.
tests/​Unit/​ReplicationCoverageRegressionTest.php Covers replication failure and recovery branches.
tests/​Unit/​ReplicationDeliveryTest.php Tests delivery, retention, and telemetry.
tests/​Unit/​SetupModuleBoundaryTest.php Enforces module ownership boundaries.
tests/​Unit/​SetupSmallHelpersTest.php Tests global configuration reset.
tests/​Unit/​SyslogSettingsWorkersTest.php Reads worker settings from their new module.
tests/​Unit/​SyslogWorkerAggregationTest.php Tests worker success aggregation.

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

Comment thread includes/functions.php
Comment thread includes/schema.php Outdated
Comment thread includes/schema.php
Comment thread includes/schema.php
Comment thread docs/setup-modules.md Outdated

@TheWitness TheWitness left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use require() and require_only(). We shouldn't really be loading all of the syslog libraries for every page rendering that's kind of bad karma. I don't know if it's lazy load or not.

@bmfmancini

Copy link
Copy Markdown
Member Author

Addressed the review in 176c29a:

  • normalize remote transactional tables to InnoDB before replication;
  • remove unsupported TEXT empty defaults;
  • reset the outbox on incoming-table truncation and drop replication tables on full uninstall;
  • lazy-load setup modules with require_once at their lifecycle/callback boundaries;
  • correct the module map and make INFO lookup plugin-relative.

Validated with the complete Pest suite: 197 passed, 961 assertions.

@bmfmancini
bmfmancini requested a review from TheWitness October 6, 2026 23:48
@TheWitness
TheWitness merged commit bb86a82 into develop Oct 7, 2026
6 checks passed
@TheWitness
TheWitness deleted the chore/extract-setup-modules branch October 8, 2026 02:21
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