Skip to content

Async actions: defaults, parameter injection, failures thrown to the queue (v1.4.0) - #16

Merged
ogorzalka merged 1 commit into
mainfrom
feat/async-framework-hooks
Oct 7, 2026
Merged

ogorzalka merged 1 commit into
mainfrom
feat/async-framework-hooks

Conversation

@ogorzalka

Copy link
Copy Markdown
Member

What the framework needs for Async Actions phase 3, released as v1.4.0.

Async::setDefaults(tries:, backoff:, asUser:)

The options every registration starts from, validated like tries() and backoff(). The framework will set them from config/hooks.php (tries, as_user, queue.backoff in the design doc). Chained options still override them.

Async::injectParametersUsing($resolver, ?$isInjectable)

Design doc: "the other typed parameters are injected by the container". Opt-in: without a resolver nothing changes.

  • By default a parameter is injected when its type is a class or interface that does not travel as a hook argument. Builtins, unions, unknown classes, WordPress objects, enums, dates, JsonSerializable and AsyncContext stay hook arguments. A predicate can replace that rule.
  • Injected parameters are not requested from WordPress (hookArgumentCount()), so they can sit anywhere. send(int $postId, Mailer $mailer, AsyncContext $context, ?WP_Post $post = null) registers for 2 hook arguments.
  • A parameter with no hook argument left takes its default value, so a later context or injected parameter still gets its own.

Async::receive($message, throwOnFinalFailure: true)

For the framework's RunAsyncAction job. The last failure is fired as pollora/async/failed, then thrown instead of reported, so the Laravel queue records it in failed_jobs and logs it once. Retries still happen while attempts are left; a deleted referenced object is still dropped silently; a missing handler or an unreadable payload throws.

Tests

254 passed, 20 new. The real-WordPress suite (18) still passes. PHPStan level 5 and Pint pass. The CHANGELOG is dated 1.4.0, and the README gains a "Dependencies" paragraph.

@ogorzalka
ogorzalka merged commit 5c59a09 into main Oct 7, 2026
5 checks passed
@ogorzalka
ogorzalka deleted the feat/async-framework-hooks branch October 7, 2026 15:35
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