From eafafe0752a8a68d18e89f4be2deaf697bbdf15f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= Date: Thu, 8 Jan 2026 11:09:11 +0100 Subject: [PATCH] [BUGFIX] Respect changed `stopIfNecessary()` signature `\Illuminate\Queue\Worker::stopIfNecessary()` method signature has changed from ```php protected function stopIfNecessary( WorkerOptions $options, $lastRestart, $job = null ) {} ``` to ```php protected function stopIfNecessary( WorkerOptions $options, $lastRestart, $startTime = 0, $jobsProcessed = 0, $job = null ) {} ``` between `7.x` and `8.x` of depending package `illuminate/queue` [1][2] and a valid breaking change between major versions. The changed signature has not been respected and mitigated with allowing `illuminate/queue:8.x`, leading to following exception in case a interop is used: ``` Unsupported operand types: float - \CustomJobObject (0) Illuminate\Queue\Worker->stopIfNecessary( Object(Illuminate\Queue\WorkerOptions), NULL, Object(FES\JobQueue\Job\Job) ) ``` To mitigate the error, this change: * Modifies `\Enqueue\LaravelQueue\Worker` to track the `start_time` and the number of `processed` jobs with an configured interop, mainly in `Worker:deamon()` and `Worker::runNextJob()`. * Modifies `Worker::onPostMessageReceived()` to call `stopIfNecessary()` passing the job as last argument and providing the new inbetween options to mitigate the error message. This package `enqueue/laravel-queue` changed the supported versions of the dependency package `illuminate/queue` on `patchlevel` releases and considerable violating semver and making it now impossible to release this fix for the target version with older `illuminate/queue` constraints. Following versions would need fixes also changing the illuminate/queue constraints: ``` * 0.10.3 -> added illuminate/queue:^8.0 support and failed to repsect the changed method signature for 8, or better to say to deal with different argument signatures <8.0 and >= 8.0. * 0.10.6 -> added `illuminate/queue:^9.0` support * 0.10.19 -> removed `illuminate/queue` support for ^6.0, ^7.0 and ^8.0. * 0.10.20 -> removed `^9.0` and added `^11.0` support for `illuminate/queue` * 0.10.21 -> removed `^10.0` and added `^12.0` support ``` Adding additional major version support of dependencies is not considerable breaking, and not respecting the method change can be taken as `bug`. However, dropping major version support of dependencies is considerable breaking and **must** have gained a `major` version bump for this package already. The fix can now only be made on top, not fixing it for the older releases and consumers requiring the fix with `illuminate/queue` versions `^8.0 | ^9.0 | ^10.0`. [1] https://github.com/laravel/framework/pull/33449 [2] https://github.com/laravel/framework/commit/441a85ac71deecdd1ad28c99728741a52f879d36 --- src/Worker.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Worker.php b/src/Worker.php index e2696d9..050e0d7 100644 --- a/src/Worker.php +++ b/src/Worker.php @@ -42,6 +42,10 @@ class Worker extends \Illuminate\Queue\Worker implements protected $extensions = []; + protected $processed = 0; + + protected $startTime = 0; + public function daemon($connectionName, $queueNames, WorkerOptions $options) { $this->connectionName = $connectionName; @@ -56,6 +60,7 @@ public function daemon($connectionName, $queueNames, WorkerOptions $options) parent::daemon($connectionName, $this->queueNames, $options); return; } + $this->startTime = hrtime(true); $context = $this->queue->getQueueInteropContext(); $queueConsumer = new QueueConsumer($context, new ChainExtension( @@ -63,6 +68,7 @@ public function daemon($connectionName, $queueNames, WorkerOptions $options) )); foreach (explode(',', $queueNames) as $queueName) { $queueConsumer->bindCallback($queueName, function() { + $this->processed++; $this->runJob($this->job, $this->connectionName, $this->options); return Result::ALREADY_ACKNOWLEDGED; @@ -87,6 +93,8 @@ public function runNextJob($connectionName, $queueNames, WorkerOptions $options) return; } + $this->startTime = hrtime(true); + $context = $this->queue->getQueueInteropContext(); $queueConsumer = new QueueConsumer($context, new ChainExtension($this->getAllExtensions([ @@ -96,6 +104,7 @@ public function runNextJob($connectionName, $queueNames, WorkerOptions $options) foreach (explode(',', $queueNames) as $queueName) { $queueConsumer->bindCallback($queueName, function() { + $this->processed++; $this->runJob($this->job, $this->connectionName, $this->options); return Result::ALREADY_ACKNOWLEDGED; @@ -143,7 +152,7 @@ public function onMessageReceived(MessageReceived $context): void public function onPostMessageReceived(PostMessageReceived $context): void { - $this->stopIfNecessary($this->options, $this->lastRestart, $this->job); + $this->stopIfNecessary($this->options, $this->lastRestart, $this->startTime, $this->processed, $this->job); if ($this->stopped) { $context->interruptExecution();