lucid icon indicating copy to clipboard operation
lucid copied to clipboard

Laravel 10 upgrade

Open PickySimon opened this issue 2 years ago • 5 comments

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();
    }
}

PickySimon avatar Feb 15 '23 22:02 PickySimon

Support for Laravel 10 would be really appreciated...

apps-in-progress avatar Feb 27 '23 22:02 apps-in-progress

https://github.com/lucidarch/lucid/pull/49

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

NayThuKhant avatar Mar 13 '23 06:03 NayThuKhant

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"

ksimenic avatar May 17 '23 14:05 ksimenic

@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 avatar Mar 29 '24 15:03 websmurf

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 https://github.com/ksimenic/lucid/pull/4

websmurf avatar Mar 29 '24 16:03 websmurf