Skip to content

[12.x] Add documentation for remaining propagated queued listener options #10633

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

Merged

Conversation

stevebauman
Copy link
Contributor

There are some queued listener options that are available but are undocumented:

  • $timeout property
  • $failOnTimeout property
  • $afterCommit property
  • ShouldBeEncrypted interface
  • middleware() method

https://github.com/laravel/framework/blob/c82b43b757c608c0afc1b549aa802b12cc847f7c/src/Illuminate/Events/Dispatcher.php#L666-L687

This PR adds documentation for these carrying over the same language as the queued jobs documentation so developers are aware that they are available.

/**
 * Propagate listener options to the job.
 *
 * @param  mixed  $listener
 * @param  \Illuminate\Events\CallQueuedListener  $job
 * @return mixed
 */
protected function propagateListenerOptions($listener, $job)
{
    return tap($job, function ($job) use ($listener) {
        $data = array_values($job->data);

        if ($listener instanceof ShouldQueueAfterCommit) {
            $job->afterCommit = true;
        } else {
            $job->afterCommit = property_exists($listener, 'afterCommit') ? $listener->afterCommit : null;
        }

        $job->backoff = method_exists($listener, 'backoff') ? $listener->backoff(...$data) : ($listener->backoff ?? null);
        $job->maxExceptions = $listener->maxExceptions ?? null;
        $job->retryUntil = method_exists($listener, 'retryUntil') ? $listener->retryUntil(...$data) : null;
        $job->shouldBeEncrypted = $listener instanceof ShouldBeEncrypted;
        $job->timeout = $listener->timeout ?? null;
        $job->failOnTimeout = $listener->failOnTimeout ?? false;
        $job->tries = $listener->tries ?? null;

        $job->through(array_merge(
            method_exists($listener, 'middleware') ? $listener->middleware(...$data) : [],
            $listener->middleware ?? []
        ));
    });
}

@taylorotwell taylorotwell merged commit 48e782c into laravel:12.x Jul 22, 2025
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