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

Laravel 10 upgrade #46

Open
PickySimon opened this issue Feb 15, 2023 · 5 comments
Open

Laravel 10 upgrade #46

PickySimon opened this issue Feb 15, 2023 · 5 comments

Comments

@PickySimon
Copy link

In laravel 10, I think Jobs now respond with Illuminate\Foundation\Bus\PendingDispatch objects rather than the response of what the handle method has.

In feature:

$this->run(GenerateUUIDJob::class);

now responds with

Illuminate\Foundation\Bus\PendingDispatch^ {#9196 // app/Models/Traits/HasUuid.php:36
  #job: App\Domains\Uid\Jobs\GenerateUUIDJob^ {#9197}
  #afterResponse: false
}

instead of the response of what the handle method does:

class GenerateUUIDJob extends Job
{

    public function __construct()
    {
    }

    public function handle(): string
    {
        return Str::orderedUuid();
    }
}
@apps-in-progress
Copy link

Support for Laravel 10 would be really appreciated...

@NayThuKhant
Copy link

#49

Please refer to this PR to solve the problem with Laravel 10.x

@ksimenic
Copy link

Feel free to use my fork https://github.com/ksimenic/lucid. It has all optimizations for Laravel 10.

All you need to do is to add following in your composer.json

    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/ksimenic/lucid"
        }
    ],

and then require

"lucidarch/lucid": "dev-latest"

@websmurf
Copy link

@ksimenic we are currently using your fork in combination with laravel 10; but are running into an issue where that all jobs and operation that have the ShouldQueue interface are still executed on the sync queue.

That's caused by this little piece of code: https://github.com/laravel/framework/blob/11.x/src/Illuminate/Bus/Dispatcher.php#L92 that always forces execution to the sync queue.

Any idea what the best option would be to get the 'old' behaviour back?
Using the runInQueue method from the UnitDispatcher currently requires me to override the 3rd argument in all calls because we use different queue names compared to the name 'default'

@websmurf
Copy link

websmurf commented Mar 29, 2024

Alright, have looked, but the least impact way in my option will be to alter the UnitDispatcher on line 58:

            $result = $this->dispatchSync($unit);
        }

to:

            if ($unit instanceof ShouldQueue) {
                return $this->dispatch($unit);
            }

            $result = $this->dispatchSync($unit);
        }

Have created a pull request for this ksimenic#4

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

No branches or pull requests

5 participants