Skip to content

refactor: let #[Schedule] run without Laravel - #466

Open
ogorzalka wants to merge 1 commit into
release/v13.36.0from
refactor/schedule-decoupling
Open

ogorzalka wants to merge 1 commit into
release/v13.36.0from
refactor/schedule-decoupling

Conversation

@ogorzalka

Copy link
Copy Markdown
Member

First step of extracting pollora/schedule (roadmap, medium term: "keep only WP-Cron in the package"). Nothing moves yet.

What changes

  • ScheduleDiscovery, the part of the module that runs on WP-Cron alone, no longer uses Illuminate\Support\Str and class_basename(): it derives default hook names itself (NightlyReports::compile() → nightly_reports_compile). A parity test pins the result to Str::snake() on several shapes of names, so hooks already scheduled under a derived name keep it.
  • tests/Unit/Schedule/ScheduleDiscoveryTest.php: the first tests that run the discovery: each method scheduled on its hook (named or derived) with its recurrence and arguments, the schedules WordPress does not know (Every::MONTH, Interval) added through cron_schedules, the method run with its arguments when the hook fires.
  • tests/Unit/Schedule/PackageBoundaryTest.php: ScheduleDiscovery may only use the attributes, discovery, PSR logging and WP-Cron. It fails on the previous code (also uses 'Illuminate\Support\Str').

The bridge to Laravel's scheduler (wordpress.use_laravel_scheduler: Scheduler, its events and jobs, the wp_events table) is Laravel by nature and stays in the framework.

Checks

1888 tests, PHPStan 0, Pint and Rector clean. Independent of #464 and #465.

ScheduleDiscovery derives default hook names itself, matching Str::snake() so scheduled hooks keep their name. Adds the first tests that run the discovery, a parity test and an architecture test; the bridge to Laravel's scheduler stays in the framework.
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.

1 participant