Repository navigation
Model WP-Cron events in the lifecycle idempotency check - #168
Merged
Merged
Conversation
schlessera
added a commit
to mwpd/content-freshness
that referenced
this pull request
Oct 23, 2026
Ported from mwpd/basic-scaffold@86697de (mwpd/basic-scaffold#168). It replaces the plugin's own cron model in the check.
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.
Closes #159
What changed
The lifecycle idempotency check in
CompositionRootContractnow models WP-Cron.LifecycleEffectsstubswp_schedule_event(),wp_schedule_single_event(),wp_next_scheduled(),wp_unschedule_event()andwp_clear_scheduled_hook()and records events per hook, keyed by timestamp andmd5( serialize( $args ) )as WordPress does. Anactivate()that schedules at a new time or with new arguments on every call is now reported aschanges the cron events of "<hook>" again. Four fixtures cover it (two reported, awp_next_scheduled()-guarded step and an identical double schedule passing), anddocs/architecture-rules.mdlists cron events among the recorded effects and describes the model.Why this shape
The model follows the issue: one entry per hook in the snapshot, so the existing effect comparison and message format work unchanged.
serialize()is needed to key arguments exactly as WordPress does, so that line carries a named, reasonedphpcs:ignorefor the one WPCS sniff. The ten-minute single-event window, the schedule filters and$wp_errorstay out of scope as the issue says.Proof
The new tests failed before the change (
Call to undefined function ...wp_schedule_event(); the contract assertions for the two broken fixtures failed):Tests: 37, Assertions: 80, Errors: 6, Failures: 2inLifecycleEffectsTestandCompositionRootContractTest. After the change, inphp:8.3-cli:In the Docker image's default 128 MB memory limit the
phpstan-rulessuite runs out of memory at the end of the run, on this branch and independent of this change; withmemory_limit=-1it passes.Checklist
composer testandcomposer lintpass locally, and CI is green on the current head.breakingand a ruling.Anything left open
Nothing.