v0.3.1 — self-healing cron scheduling (PRV_Cron_Guard)

Add PRV_Cron_Guard: idempotent init-hook guard that re-schedules
prv_weekly_probe and prv_daily_prune when missing (e.g. after
an rsync deploy that bypasses the activation hook).

- New class: includes/core/class-prv-cron-guard.php
  - Hooks on init; two wp_next_scheduled() checks on hot path
  - Delegates to PRV_Cron::schedule() and PRV_Prune_Cron::schedule()
    so recurrence + offset are always canonical (no inline divergence)
  - Idempotent: no-op when events already scheduled
- PRV_Plugin::init(): wires PRV_Cron_Guard::register_hooks()
- Tests: tests/unit/test-cron-guard.php (missing, idempotent, recurrence)
- Bump version 0.3.0 -> 0.3.1 (header + PRV_VERSION constant + bootstrap)
- CHANGELOG: [0.3.1] entry
This commit is contained in:
peptiderepo
2026-06-15 13:52:12 +00:00
parent 2e2c72cac6
commit a23644b1af
6 changed files with 196 additions and 4 deletions

View File

@@ -17,13 +17,15 @@ declare(strict_types=1);
* Who triggers: plugins_loaded action (pr-vision.php).
* Dependencies: PRV_Upgrader, PRV_Cron, PRV_Admin_Page, PRV_Settings_Page,
* PRV_Settings_Controller, PRV_Costs_Page, PRV_Call_Log_Page,
* PRV_Call_Detail_Ajax, PRV_Prune_Cron, PRV_Collector_Registry.
* PRV_Call_Detail_Ajax, PRV_Prune_Cron, PRV_Cron_Guard,
* PRV_Collector_Registry.
*
* @see ARCHITECTURE.md -- Boot sequence diagram.
* @see class-prv-upgrader.php -- Runs migrations on every boot.
* @see class-prv-costs-page.php -- [v0.3.0] Costs admin sub-page.
* @see class-prv-call-log-page.php -- [v0.3.0] Call Log admin sub-page.
* @see class-prv-prune-cron.php -- [v0.3.0] Daily prune cron.
* @see class-prv-cron-guard.php -- [v0.3.1] Self-healing cron guard.
* @package PrVision
*/
class PRV_Plugin {
@@ -50,6 +52,9 @@ class PRV_Plugin {
$prune = new PRV_Prune_Cron();
$prune->register_hooks();
$guard = new PRV_Cron_Guard();
$guard->register_hooks();
if ( is_admin() ) {
$page = new PRV_Admin_Page();
$page->register_hooks();