feat(settings-module): implement Settings_Module — settings, cleanup cron (#99)#109
Merged
Conversation
22b7f7a to
c5d904f
Compare
…anup cron, asset enqueuer (#99) Settings_Module::boot() registers Settings_Page, the manual cleanup handler, and the asset enqueuer via Admin_Manager; wires sybgo_cleanup_old_events via Cron_Manager. All callbacks are public named methods for testability. Sybgo::init() now calls $cron->init() and $admin->init() directly on the shared manager instances, fixing two latent bugs: cron callbacks registered by modules were never wired (Cron_Manager::init() was not called), and Dashboard_Widget / Reports_Page were registered but never init()-ed (Admin_Manager::init() was called on a separate instance). Adds SYBGO_PLUGIN_URL to phpstan-bootstrap.php so PHPStan resolves the constant. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nd module table Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
a0b43b7 to
16ff43b
Compare
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.
Description
Settings_Module::boot()owns the Settings_Page registration, the manual cleanup form handler, the admin asset enqueuer, and thesybgo_cleanup_old_eventsdaily cron. All callbacks are public named methods on the module. This PR also fixes two latent bugs: cron callbacks registered by modules were never wired (becauseCron_Manager::init()was never called), and Dashboard_Widget / Reports_Page pages were registered but theirinit()methods were never invoked.Closes #99
Type of change
Detailed scenario
What was tested
No manual testing performed for the pure refactoring side. However, this PR fixes two latent bugs (cron callbacks and admin pages never being initialized) that should be verified manually on a real WordPress install:
wp cron event run sybgo_freeze_weekly_report— verified the freeze ran and a log entry appeared, confirmingReport_Module's cron callback is now properly wired viaCron_Manager::init().Dashboard_Widget::init()is now called viaAdmin_Manager::init()on the correct shared instance.Automated coverage: 7 unit tests in
SettingsModuleTest— registration assertions, callback pointer tests, and cleanup cron callback paths (rows deleted and no-rows paths).How to test
wp-env start).options-general.php?page=sybgo-settings&cleanup-done=N.wp cron event list | grep sybgosybgo_freeze_weekly_report,sybgo_send_report_emails,sybgo_cleanup_old_events,sybgo_retry_failed_emailsall present.wp cron event run sybgo_cleanup_old_events— no errors expected.cd wp-plugin && vendor/bin/phpunit --testsuite Unit --filter SettingsModuleTestExpected: 7 tests, all green.
Affected Features & Quality Assurance Scope
Settings_Page)Dashboard_Widget) — now correctly initialized via sharedAdmin_ManagerReports_Page) — now correctly initialized via sharedAdmin_ManagerCron_Manager::init()Technical description
Documentation
Initialization flow fix
Sybgo::init()previously called$this->init_admin()which created a separateAdmin_Managerinstance from the one passed to modules, so Dashboard_Widget and Reports_Page (registered byReport_Module::boot()) were neverinit()-ed. Similarly,Cron_Manager::init()was never called, so cron callbacks registered by modules via$cron->register()were accumulated in the registration queue but never scheduled or wired.The fix:
Sybgo::init()now calls$cron->init()and (in admin context)$admin->init()on the shared manager instances after allboot()calls. The legacyinit_admin(),init_cron_schedules(),cleanup_old_events_callback(),add_cron_intervals(), andcreate_settings_page()methods are deleted fromSybgo.Sybgo::get_cron_hooks()is kept as a thin wrapper aroundCron_Manager::get_hooks()for use bydeactivate()— cleanup is sub-issue #100.See wp-plugin/docs/development.md — "Feature Module Architecture" section updated with the 4-step initialization sequence and a module responsibility table.
SYBGO_PLUGIN_URLadded tophpstan-bootstrap.phpso PHPStan resolves the constant used inSettings_Module::enqueue_admin_assets().New dependencies
None.
Risks
The fix to
Admin_Manager::init()calling now means Dashboard_Widget and Reports_Page are initialized for the first time via the shared instance. This is the correct behaviour — it was previously a latent bug that they were never initialized. The E2E suite covers both pages.Mandatory Checklist
Code validation
Code style
Unticked items justification
N/A — all checklist items apply and are satisfied.
Additional Checks