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

[8.x] Deprecate dispatch_now & dispatchNow #36834

Merged
merged 2 commits into from
Apr 1, 2021
Merged

Conversation

driesvints
Copy link
Member

@driesvints driesvints commented Mar 31, 2021

Deprecate dispatch_now helper and dispatchNow method on the Dispatchable trait so we can remove it in a future Laravel version. See #36743 (comment)

@SjorsO
Copy link
Contributor

SjorsO commented Apr 1, 2021

Is the dispatchNow() method on the Dispatchable trait also deprecated?

@driesvints
Copy link
Member Author

@SjorsO was doubting that but yeah we can do that as well. Pushed a commit.

@driesvints driesvints changed the title [8.x] Deprecate dispatch_now [8.x] Deprecate dispatch_now & dispatchNow Apr 1, 2021
@taylorotwell taylorotwell merged commit d8a53a0 into 8.x Apr 1, 2021
@taylorotwell taylorotwell deleted the deprecate-dispatch-now branch April 1, 2021 13:10
@kawax
Copy link
Contributor

kawax commented Apr 2, 2021

dispatchNow and dispatchSync work a little differently.

class FooJob implements ShouldQueue
{
    public function handle()
    {
        return 'bar';
    }
}
$bar = FooJob::dispatchSync();
//?

$bar = FooJob::dispatchNow();
//bar

If ShouldQueue is not implemented

class FooJob
{
    public function handle()
    {
        return 'bar';
    }
}
$bar = FooJob::dispatchSync();
//bar

$bar = FooJob::dispatchNow();
//bar

I'm using dispatchNow to get the return value, so I still need it.

@driesvints
Copy link
Member Author

@kawax please see the link in my first comment.

@renoirtech
Copy link

Guys, after a shift from 7 to 8 we've noticed that dispatchSync does not work just like dispatchNow, was this the purpose or we can send a PR?

We've used to get returns from synchronous tasks and dispatchSync just return 0 (false) values.

@driesvints
Copy link
Member Author

@renoirtech see #37023

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.

5 participants