Skip to content

Commit 5d1b81d

Browse files
must collect the unparsed event and payload when deferring events (#57453)
1 parent d439ff5 commit 5d1b81d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Illuminate/Events/Dispatcher.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,12 @@ public function dispatch($event, $payload = [], $halt = false)
268268
// When the given "event" is actually an object we will assume it is an event
269269
// object and use the class as the event name and this event itself as the
270270
// payload to the handler, which makes object based events quite simple.
271-
[$isEventObject, $event, $payload] = [
271+
[$isEventObject, $parsedEvent, $parsedPayload] = [
272272
is_object($event),
273273
...$this->parseEventAndPayload($event, $payload),
274274
];
275275

276-
if ($this->shouldDeferEvent($event)) {
276+
if ($this->shouldDeferEvent($parsedEvent)) {
277277
$this->deferredEvents[] = func_get_args();
278278

279279
return null;
@@ -283,16 +283,16 @@ public function dispatch($event, $payload = [], $halt = false)
283283
// transaction is successful, we'll register a callback which will handle
284284
// dispatching this event on the next successful DB transaction commit.
285285
if ($isEventObject &&
286-
$payload[0] instanceof ShouldDispatchAfterCommit &&
286+
$parsedPayload[0] instanceof ShouldDispatchAfterCommit &&
287287
! is_null($transactions = $this->resolveTransactionManager())) {
288288
$transactions->addCallback(
289-
fn () => $this->invokeListeners($event, $payload, $halt)
289+
fn () => $this->invokeListeners($parsedEvent, $parsedPayload, $halt)
290290
);
291291

292292
return null;
293293
}
294294

295-
return $this->invokeListeners($event, $payload, $halt);
295+
return $this->invokeListeners($parsedEvent, $parsedPayload, $halt);
296296
}
297297

298298
/**

0 commit comments

Comments
 (0)