Skip to content

feat(email-module): implement Email_Module — send and retry email cron callbacks (#97)#107

Closed
MathieuLamiot wants to merge 7 commits into
developfrom
feat/ai-module-98
Closed

feat(email-module): implement Email_Module — send and retry email cron callbacks (#97)#107
MathieuLamiot wants to merge 7 commits into
developfrom
feat/ai-module-98

Conversation

@MathieuLamiot

Copy link
Copy Markdown
Owner

Description

Email_Module::boot() owns the sybgo_send_report_emails and sybgo_retry_failed_emails cron registrations. Both callbacks are public named methods (send_report_emails_callback, retry_failed_emails_callback), making them independently testable. The anonymous closure versions in Sybgo::init_cron_schedules() are removed.

Closes #97

Type of change

  • New feature (non-breaking change which adds functionality).
  • Bug fix (non-breaking change which fixes an issue).
  • Enhancement (non-breaking change which improves an existing functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).
  • Sub-task of Introduce Feature Modules to own WP integration by domain #93
  • Chore
  • Release

Detailed scenario

What was tested

No manual testing performed: this is a pure internal reorganisation. The cron hook names, schedules, and callback logic are identical to what was in Sybgo. The (int) cast on the report id is preserved as a regression guard for issue #68 ($wpdb returns string ids; Email_Manager::send_report_email() is strictly typed against int).

Automated coverage: 5 unit tests in EmailModuleTest — cron registration, callback pointer assertions, the #68 regression test (string id cast), and the no-frozen-report early-return path.

How to test

  1. Check out this branch and activate the plugin.
  2. Verify both email cron events are scheduled:
    wp cron event list | grep sybgo_send_report_emails
    wp cron event list | grep sybgo_retry_failed_emails
  3. Run a manual send: wp cron event run sybgo_send_report_emails
    Expected: no PHP type errors; email log updated.
  4. Run unit tests: cd wp-plugin && vendor/bin/phpunit --testsuite Unit --filter EmailModuleTest
    Expected: 5 tests, all green.

Affected Features & Quality Assurance Scope

  • Weekly digest email sending
  • Failed email retry cron
  • SybgoCronCallbacksTest removed; tests migrated to EmailModuleTest

Technical description

Documentation

Both crons are registered via Cron_Manager::register() inside Email_Module::boot(). Callback methods are public on the module instance, matching the [$this, 'method_name'] pattern established by Report_Module. See wp-plugin/docs/development.md for the Feature Module Architecture overview.

New dependencies

None.

Risks

None identified. The (int) cast regression guard from issue #68 is preserved verbatim.

Mandatory Checklist

Code validation

  • I validated all the Acceptance Criteria.
  • I triggered all changed lines of code at least once without new errors/warnings/notices.
  • I implemented built-in tests to cover the new/changed code.

Code style

  • I wrote a self-explanatory code about what it does.
  • I protected entry points against unexpected inputs.
  • I did not introduce unnecessary complexity.
  • Output messages (errors, notices, logs) are explicit enough for users to understand the issue and are actionable.

Unticked items justification

Manual testing not performed: pure internal reorganisation; E2E suite covers email sending end-to-end.

Additional Checks

  • In the case of complex code, I wrote comments to explain it.
  • When possible, I prepared ways to observe the implemented system (logs, data, etc.).
  • I added error handling logic when using functions that could throw errors (HTTP/API request, filesystem, etc.)

MathieuLamiot and others added 7 commits May 19, 2026 08:24
#94)

Introduces the wp-plugin/modules/ directory with Module_Interface and five
empty feature modules (Event, Report, Email, AI, Settings). Sybgo::init()
now creates the three managers and boots all modules via build_modules()
before delegating to the legacy init_*() sub-methods, which remain intact
until each module's boot() is fully implemented in sub-issues #95#99.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ction

Documents the new wp-plugin/modules/ directory and the Module_Interface
pattern introduced in #94. Explains where new domain wiring belongs and
the boot() registration-only contract.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…API, ability (#95)

Moves event tracking init, sybgo_init_api(), and sybgo/track-events ability
registration from Sybgo::init_event_tracking() and init_abilities() into
Event_Module::boot(). Ability registration is deferred to the 'init' hook at
priority 5; Ability_Manager::init() is scheduled at priority 20 so it captures
all module-registered abilities. Adds EventModuleTest covering tracker storage,
API side-effect, and deferred ability registration.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…freeze cron (#96)

Moves Dashboard_Widget and Reports_Page registration and the
sybgo_freeze_weekly_report cron callback from Sybgo into Report_Module::boot()
and the new named freeze_report_callback() method. Removes create_dashboard_widget(),
create_reports_page(), and freeze_weekly_report_callback() from class-sybgo.php.
Adds ReportModuleTest covering admin page registration, cron wiring, and callback
logic for both frozen and no-active-report paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…n callbacks (#97)

Moves send_report_emails_callback() and retry_failed_emails_callback() from
Sybgo into Email_Module as public named methods. Both crons are now registered
via CronManager in Email_Module::boot(). EmailModuleTest migrates the #68
regression tests (string-id-to-int cast + no-op path) from the deleted
SybgoCronCallbacksTest.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ity (#98)

AI_Module::boot() defers the sybgo/generate-summary ability registration to
the 'init' hook at priority 5 so __() evaluates after the text domain loads.
Removes the now-redundant init_abilities() method from Sybgo — both abilities
are owned by their respective modules (Event_Module and AI_Module).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…Module

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@MathieuLamiot MathieuLamiot force-pushed the feat/report-module-96 branch 2 times, most recently from e7d8166 to 6c3b4e4 Compare May 19, 2026 16:16
Base automatically changed from feat/report-module-96 to develop May 19, 2026 16:26
@MathieuLamiot

Copy link
Copy Markdown
Owner Author

Superseded by #112 (correct head branch feat/email-module-97 → develop).

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.

Implement Email_Module: send and retry email cron callbacks

1 participant