Skip to content

[2.x] fix: give Clockwork the queue driver under Flarum's routing wrapper - #48

Merged
imorland merged 1 commit into
2.xfrom
ed/unwrap-routing-queue
Oct 10, 2026
Merged

imorland merged 1 commit into
2.xfrom
ed/unwrap-routing-queue

Conversation

@ernestdefoe

Copy link
Copy Markdown
Contributor

Fixes #0000 (no issue; found during an N+1 audit of FoF's 2.x extensions)

Changes proposed in this pull request:
With an async queue driver (database, or Redis through fof/redis or fof/horizon), Flarum 2 wraps flarum.queue.connection in Flarum\Queue\RoutingQueue so that jobs are routed onto their registered queues. The wrapper implements only Illuminate\Contracts\Queue\Queue. Clockwork's LaravelQueueDataSource type-hints the concrete Illuminate\Queue\Queue (it calls createPayloadUsing on it), so the provider's boot threw on every web request:

TypeError: Clockwork\DataSource\LaravelQueueDataSource::__construct(): Argument #1 ($queue) must be of type
Illuminate\Queue\Queue, Flarum\Queue\RoutingQueue given, called in .../ClockworkServiceProvider.php on line 91

The provider now hands Clockwork the wrapped driver (RoutingQueue::getDriver()). The sync driver is never wrapped, so sites on it were not affected and see no change. On a core that predates RoutingQueue, the instanceof check is simply false.

Reviewers should focus on:
Core does the same unwrap internally (QueueServiceProvider::unwrapQueue()), for the same reason.

Tested on Flarum 2.0.0-rc.8 (Composer install, MariaDB, all FoF 2.x extensions enabled), with queue.driver set to database:

/api/discussions /
fof/clockwork 2.x 500 (the TypeError above) 500
this branch 200 200

With the sync driver, both answer 200. PHPStan is clean. The extension has no test suite.

Confirmed

  • Frontend changes: tested on a local Flarum installation. (no frontend changes)
  • Backend changes: tested on a Flarum 2.0.0-rc.8 forum as above; no test suite in this repository.

🤖 Generated with Claude Code

With a database or Redis queue, Flarum 2 wraps the connection in a
RoutingQueue, which implements only the queue contract. Clockwork's
LaravelQueueDataSource requires Illuminate\Queue\Queue, so building it threw
a TypeError on every web request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ernestdefoe
ernestdefoe requested a review from a team as a code owner October 8, 2026 04:13
@imorland
imorland merged commit 5f0eea2 into 2.x Oct 10, 2026
10 checks passed
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.

2 participants