Skip to content

Releases

v2.0.3

Choose a tag to compare

@ogorzalka ogorzalka released this 26 Nov 09:59
a27f9b8

Fixed

  • Registering an invokable object (Action::add('init', new Handler)) without an argument count threw a TypeError, and a static method written as a string ('Handler::run') threw CallbackAnalysisFailedException: the parameters were counted with ReflectionFunction, which reads neither. They are now read from the object's __invoke() and from the named static method.
  • An asynchronous handler whose descriptor names a private or protected method was retried as many times as tries allowed, each attempt failing the same way with The handler of … is not callable. Resolving the descriptor now fails at once with an UnresolvableHandler that says the method is not public.

v2.0.2

Choose a tag to compare

@ogorzalka ogorzalka released this 25 Nov 11:07
22bc9be

Fixed

  • A closure registered after another closure was freed no longer inherits that closure's argument count. The count was cached under the closure's object ID, which PHP hands to the next closure once the first is freed, so WordPress could be told to pass a callback too few arguments (an ArgumentCountError) or too many. The count is now held by the closure itself and goes with it.

Changed

  • AbstractHook throws named exceptions from the new Pollora\Hook\Domain\Exceptions namespace instead of a bare \RuntimeException: HookMethodNotFoundException (a class registered without a method has no method named after the hook), CallbackResolutionFailedException (the class of a callback cannot be built; it wraps the cause, with its code) and CallbackAnalysisFailedException (reflection cannot read the callable). Their messages say how to fix the problem. They extend HookException, which extends \RuntimeException, so a catch (\RuntimeException) keeps working and the existing message prefixes (Failed to resolve '…', Method '…' not found in class '…', Failed to analyze callable:) are unchanged
  • The daily recovery task is registered through Recovery::run(), which returns nothing as an action callback must; Recovery::recover() still returns the number of executions scheduled again

Internal

  • The WordPress suite (composer test:integration, still available as composer test:wordpress) also covers the Action and Filter facades against WordPress's own hook tables, and no longer defines DISABLE_WP_CRON a second time when the installed wp-config.php already does
  • The Architecture test suite runs tests/Arch.php, which the default run left out
  • PHPStan runs with szepeviktor/phpstan-wordpress (WordPress stubs and rules), at level 5; the ignores it makes unnecessary are removed and unmatched ignores are reported again
  • The WordPress test fixtures use wp_doing_cron() instead of the DOING_CRON constant
  • The unserialize() of a queued closure carries a nosemgrep justification: the payload's HMAC, keyed from wp_salt(), is checked before it is read

v2.0.1

Choose a tag to compare

@ogorzalka ogorzalka released this 14 Oct 13:50
7ee8f62

Accepts pollora/schedule ^1.0 alongside ^0.1.2. No code change.

v2.0.0

Choose a tag to compare

@ogorzalka ogorzalka released this 13 Oct 13:45

[2.0.0] - 2026-10-13

Asynchronous actions queue through the drivers of pollora/schedule. Work queued by 1.x runs unchanged; the only break is the two removed driver classes below.

Changed

  • WP-Cron and Action Scheduler are the drivers of pollora/schedule, which the package now requires: Async\Drivers\ScheduledDriver queues through them and keeps what is the hook's own, the message an event carries and where the payload lives. Nothing changes for what is already queued: the hook, the Action Scheduler groups (pollora or the queue name), the identifier-only WP-Cron events and the pollora_async_ options are the same, so work queued by 1.x runs once 2.0 is installed. ->async(), #[Async], Async::fake(), via() and their options do not change
  • Async::listen() keeps pollora/async/run and pollora/async/recover on WP-Cron (the pollora/schedule/protected_hooks filter), whatever driver the site gave pollora/schedule: via('wp-cron') still means WP-Cron
  • An Action Scheduler action of the hook lives in its own group and is never in the cron index of pollora/schedule

Removed

  • Async\Drivers\WpCronDriver and Async\Drivers\ActionSchedulerDriver, with no alias. Code that used them directly (the framework does not) uses ScheduledDriver::wpCron() and ScheduledDriver::actionScheduler(), or the drivers of pollora/schedule
  • WpCronDriver::handles() and claim(): use PayloadStore. The recovery task (recover(), scheduleRecovery(), RECOVERY_HOOK, RECOVERY_GRACE) moved to Async\Recovery

v1.5.0

Choose a tag to compare

@ogorzalka ogorzalka released this 09 Oct 08:31
d22b619

Added

  • AbstractHook::all() lists every registration made through a hook instance, keyed by hook name, for debugging tools that mark Pollora's callbacks
  • The pollora/async/dispatched action announces each queued handler with its payload and delay

Full Changelog: v1.4.1...v1.5.0

v1.4.1

Choose a tag to compare

@ogorzalka ogorzalka released this 07 Oct 15:49
fcdb211

Fixed

  • The runner checks that determine_locale() exists before restoring the locale, not only switch_to_locale(), so an environment that defines one without the other (a test suite, an early bootstrap) no longer fails with an undefined function.

Full Changelog: v1.4.0...v1.4.1

v1.4.0

Choose a tag to compare

@ogorzalka ogorzalka released this 07 Oct 15:35
5c59a09

Added

  • Async::setDefaults(): the attempts, backoff and asUser every asynchronous registration starts from. The framework sets them from config/hooks.php.
  • Async::injectParametersUsing(): handler parameters that are not hook arguments are injected at execution. By default, a parameter is injected when its type is a class or interface that does not travel as a hook argument (WordPress objects, enums, dates, JsonSerializable and AsyncContext do). These parameters are not requested from WordPress, so they can sit anywhere in the signature. The framework resolves them from its container.
  • Async::receive(..., throwOnFinalFailure: true): the last failure is announced through pollora/async/failed, then thrown instead of reported, for a driver whose queue records failures itself (a Laravel job then lands in failed_jobs). Retries still happen while attempts are left.

Changed

  • A handler parameter with no hook argument left takes its default value, so a later AsyncContext or injected parameter still gets its own.

Full Changelog: v1.3.0...v1.4.0

v1.3.0

Choose a tag to compare

@ogorzalka ogorzalka released this 07 Oct 13:36
6a23672

Changed

  • The default driver is now auto: Action Scheduler when a plugin bundling it is active and initialised, WP-Cron otherwise, resolved on each dispatch. A site with WooCommerce therefore queues through Action Scheduler after upgrading; payloads already queued through WP-Cron still run. Set POLLORA_ASYNC_DRIVER to wp-cron to keep the previous behaviour.
  • The WP-Cron recovery task also leaves alone a stored payload whose Action Scheduler action is still pending.
  • The type of capture() and when() callbacks is documented as callable, so closures with typed parameters pass static analysis.

Added

  • capture() on an asynchronous registration: a callback run at trigger time, in the original request, with the hook arguments; the array it returns is read back at execution through AsyncContext::get(). Captured values travel like arguments. A handler class's public capture() method is used when capture() is not called.
  • when(): queue only when the callback, given the hook arguments, returns true. It runs before the capture, and an exception it throws goes through, as it would synchronously.
  • tries(): a handler that throws is queued again, through the driver that queued it, until it has used its attempts; each failed attempt is reported, the last one is fired as pollora/async/failed. backoff() sets the seconds before each retry (default 10, 60, then 300; the last value repeats). A handler that no longer exists is not retried.
  • asUser(): run as the user who fired the hook, then remove that user. Without it the handler runs without a current user.
  • onQueue(): queue name, used as the Action Scheduler group and the Laravel queue; WP-Cron ignores it.
  • unique(): merge identical triggers (same hook, same handler, same arguments) while the first one has not started running. The lock is an option that is not autoloaded, taken atomically with add_option(), released when the first attempt starts, and expiring after unique(for: …) seconds (one day by default) if never released; the daily maintenance task deletes expired locks. A lock that cannot be stored is a queuing failure, never a silent merge.
  • action-scheduler driver, offered when a plugin bundling Action Scheduler is active and its data store is initialised (never a dependency). The payload travels whole as the action argument, the queue name becomes the group (pollora by default), and history is visible in Tools › Scheduled Actions. A payload too long for Action Scheduler's arguments (8,000 characters as JSON) is kept in an option that is not autoloaded and the action carries only its identifier.
  • Async::setAutoDrivers(): the drivers auto tries, in order.
  • Async::fake() for tests: records queued handlers instead of queuing them, whatever the driver, with Async::assertDispatched() (by class, descriptor or closure, with an optional callback receiving the payload and the delay), assertDispatchedTimes(), assertNotDispatched() and assertNothingDispatched(). Arguments are still normalized, so one that cannot travel fails here too; runDispatched() runs the recorded handlers. Assertions go through PHPUnit when it is installed.
  • Closures as asynchronous handlers, when laravel/serializable-closure is installed (suggested, not required). The closure is serialized with it and signed with an HMAC-SHA256 whose key derives from wp_salt('auth'), or is set with Async::useClosureKey(); the signature is checked before anything is unserialized, and an altered payload or a changed key fails with an explicit report. The closure is checked at registration but signed when its hook first fires, since wp_salt() is pluggable and not loaded while plugins load. A closure made from a named function or method (strlen(...), $object->method(...)) travels by that name.
  • Payloads record the driver that queued them, the queue, asUser, the backoff and the unique lock. These fields are optional, so payloads queued by 1.2.0 still run.

Full Changelog: v1.2.0...v1.3.0

v1.2.0

Choose a tag to compare

@ogorzalka ogorzalka released this 07 Oct 12:54
fea2379

Added

  • Asynchronous actions: add(...)->async() replaces each callback of the last add() call by one that queues it, at the same priority. The handler runs later, with the hook arguments and, if it declares a parameter of that type, an AsyncContext (user, site, locale, hook, trigger date, attempt).
    • Options on the returned PendingAsync: delay() (seconds or DateInterval), via() (driver), keepMissing(), and except() to keep some hooks synchronous; async(except: ...) too. A hook in except that the registration does not have throws in debug mode and is reported otherwise.
    • The handler travels by name (CallableDescriptor), its arguments in normalized form (ArgumentNormalizer: WordPress objects by reference, enums, dates, JsonSerializable; any other object rejected), all in a versioned JSON AsyncPayload. A closure or an anonymous class is rejected at registration.
    • At execution the site and locale of the original request are restored. A handler that fires its own hook does not queue itself again. A failure is reported and announced through the pollora/async/failed action, and never stops other queued handlers.
    • When queuing fails (an argument that cannot travel, an unavailable driver), debug mode (WP_DEBUG, or Async::setDebug()) throws; otherwise the incident is reported and the handler runs in place.
  • Async entry point: extend() to register a driver, driver(), reference() to carry more object kinds, reportUsing() to route incidents (PHP error log by default), setDebug(). The internal hook pollora/async/run is listened to as soon as an Action service exists. AsyncDriver and ObjectReference contracts.
  • wp-cron driver, the default: the payload is stored in an option of its own, not autoloaded (pollora_async_{id}), and the single event carries only its identifier, so the autoloaded cron option stays small. The payload is deleted when its execution starts; an event that fires twice runs once. A daily task (pollora/async/recover, scheduled the first time the driver queues) schedules again the payloads whose event was lost, for example after the cron option was reset, once they are an hour old; an unreadable stored payload is deleted. Each recovery is reported.
  • sync driver: runs the handler in the request, after the same JSON round trip.
  • Default driver, from the first of: Async::setDefaultDriver(), the POLLORA_ASYNC_DRIVER constant, the pollora/hook/async_driver filter, wp-cron. auto resolves to wp-cron for now.

Changed

  • PHP 8.3 is now the minimum version.
  • The Action contract declares async(). A class of your own implementing Pollora\Hook\Domain\Contract\Action must add public function async(string|array $except = []): PendingAsync. The adapters of the package already do.
  • Pollora\Hook\Action::add() and Pollora\Hook\Filter::add() return the adapter instead of nothing, so Action::add(...)->async() chains.
  • remove() and exists() find an asynchronous handler by the callback it was registered with.

Fixed

  • A [ClassName::class, 'method'] callback naming an instance method is now instantiated at registration, through the callback resolver when one is set, as a class name is. WordPress used to receive it as a static call and threw a TypeError when the hook fired. Static methods and classes not loaded yet are unchanged.
  • remove() and exists() accept that same [ClassName::class, 'method'] form and find the instance it was registered as. exists() now accepts a non-callable array or string as its callback.

Full Changelog: v1.1.1...v1.2.0

v1.1.1

Choose a tag to compare

@ogorzalka ogorzalka released this 07 Oct 08:10

Full Changelog: v1.1.0...v1.1.1