Skip to content

Commit 70a5459

Browse files
committed
fix Bus::dispatchChain() with closure as first in chain
1 parent e6b691a commit 70a5459

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/Illuminate/Foundation/Bus/PendingChain.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
namespace Illuminate\Foundation\Bus;
44

5+
use Closure;
6+
use Illuminate\Queue\CallQueuedClosure;
7+
use Illuminate\Queue\SerializableClosure;
8+
59
class PendingChain
610
{
711
/**
@@ -38,9 +42,13 @@ public function __construct($job, $chain)
3842
*/
3943
public function dispatch()
4044
{
41-
$firstJob = is_string($this->job)
42-
? new $this->job(...func_get_args())
43-
: $this->job;
45+
if (is_string($this->job)) {
46+
$firstJob = new $this->job(...func_get_args());
47+
} elseif ($this->job instanceof Closure) {
48+
$firstJob = new CallQueuedClosure(new SerializableClosure($this->job));
49+
} else {
50+
$firstJob = $this->job;
51+
}
4452

4553
return (new PendingDispatch($firstJob))->chain($this->chain);
4654
}

0 commit comments

Comments
 (0)