Repository navigation
Async actions: Action Scheduler driver and auto resolution - #12
Merged
Merged
Conversation
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.
Phase 2, step D: Action Scheduler driver and
autoresolution.action-schedulerdriveras_enqueue_async_action()exists and Action Scheduler is initialised (ActionScheduler::is_initialized()). Beforeaction_scheduler_initits functions exist but cannot store anything. Never a Composer dependency.onQueue()becomes the group,polloraby default. A delay usesas_schedule_single_action(), otherwiseas_enqueue_async_action(). History is visible in Tools › Scheduled Actions.capture()or, soon, a serialized closure can reach. Above 7,900, the payload is kept byPayloadStore(non-autoloaded option, claim on execution) and the action carries only its identifier. Rather than falling back to in-place execution, the work still goes through the queue.AsyncException, and a payload kept apart is forgotten.auto, now the defaultAsync::setAutoDrivers()(['action-scheduler', 'wp-cron']). Phase 3 will put the framework'squeuefirst.POLLORA_ASYNC_DRIVER=wp-cronkeeps the old behaviour. This is in the CHANGELOG.Refactor
PayloadStoretakes the non-autoloaded storage and the claim out ofWpCronDriver.WpCronDriver::OPTION_PREFIX,handles()andclaim(), public since 1.2.0, are kept and delegate to it.as_has_scheduled_action()), so it never runs a delayed action early.API fix
The PHPDoc of
capture()andwhen()wascallable(mixed...), which static analysis rejects for a closure with typed parameters such asfn (int $id) => …. It is nowcallable.Tests
Unit: 208 passed, 11 new for the driver (stubbed Action Scheduler, only available when a test asks).
Real WordPress, now with the Action Scheduler plugin active, locally and in CI (
wp plugin install action-scheduler --activate): 4 new tests, 10 in total.autochooses Action Scheduler; the payload is whole in thepolloragroup; no WP-Cron event; the queue runs in a separate process and the handler runs.onQueuesets the group.The suite's default driver stays
wp-cron(fixture filter), so the earlier tests are unchanged.PHPStan level 5 and Pint pass.