Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Fix Job delay property when dispatched through facade + data_get() closure fix #46582

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Illuminate/Collections/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function data_get($target, $key, $default = null)

if (Arr::accessible($target) && Arr::exists($target, $segment)) {
$target = $target[$segment];
} elseif (is_object($target) && isset($target->{$segment})) {
} elseif (! $target instanceof Closure && is_object($target) && isset($target->{$segment})) {
$target = $target->{$segment};
} else {
return value($default);
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Queue/DatabaseQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function pushRaw($payload, $queue = null, array $options = [])
* @param string $job
* @param mixed $data
* @param string|null $queue
* @return void
* @return mixed
*/
public function later($delay, $job, $data = '', $queue = null)
{
Expand Down
7 changes: 5 additions & 2 deletions src/Illuminate/Queue/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ protected function withCreatePayloadHooks($queue, array $payload)
*/
protected function enqueueUsing($job, $payload, $queue, $delay, $callback)
{
$delay ??= data_get($job, 'delay');

if ($this->shouldDispatchAfterCommit($job) &&
$this->container->bound('db.transactions')) {
return $this->container->make('db.transactions')->addCallback(
Expand All @@ -325,8 +327,9 @@ function () use ($payload, $queue, $delay, $callback, $job) {
*/
protected function shouldDispatchAfterCommit($job)
{
if (! $job instanceof Closure && is_object($job) && isset($job->afterCommit)) {
return $job->afterCommit;
$afterCommit = data_get($job, 'afterCommit');
if (! is_null($afterCommit)) {
return $afterCommit;
}

if (isset($this->dispatchAfterCommit)) {
Expand Down