imTigger / laravel-job-status

Add ability to track Job progress, status and result dispatched to Queue.
MIT License
407 stars 60 forks source link

Problem with Trackable trait after updating to Laravel v5.8.34 #40

Closed Blum closed 4 years ago

Blum commented 5 years ago

Hello, thank you for the nice work. Since upgrading to Laravel v5.8.34 I'm getting:

Fatal error: Trait method __sleep has not been applied, because there are collisions with other trait methods on <my job file "use" statement>

Seems like some other trait of these "Dispatchable, InteractsWithQueue, Queueable, SerializesModels" is using this method too..

Thanks

// Edit Turned out this is SerializesModels trait, which you also are using in Imtigger\LaravelJobStatus\Trackable trait. So the temporary solution is not to use SerializesModels trait in the trackable jobs..

mrvnklm commented 4 years ago

Have a look at

trait Trackable
{
    use SerializesModels {
        __sleep as traitSleep;
    }

and

    public function __sleep()
    {
        if (!$this->statusId && $this->shouldTrack) {
            $this->prepareStatus();
        }
        return $this->traitSleep();
    }

There is no need to use SerializeModels anymore because its used in Trackable Trait und the sleep method is also being called