From 232150a8141d7460daa01cd639444a3149d55d50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ribeiro?= Date: Sun, 11 Dec 2022 15:31:27 +0000 Subject: [PATCH 1/4] Fixed bug on Batchs Jobs Table If the batch has more than 1000 errors the function Bus::findBatch() fails because the database cuts down the words when reach is limit and then the seventh argument returns null because can't be json decoded. --- src/Illuminate/Queue/Console/stubs/batches.stub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Queue/Console/stubs/batches.stub b/src/Illuminate/Queue/Console/stubs/batches.stub index 60be4d2b2ef1..12b99d23081e 100644 --- a/src/Illuminate/Queue/Console/stubs/batches.stub +++ b/src/Illuminate/Queue/Console/stubs/batches.stub @@ -19,7 +19,7 @@ return new class extends Migration $table->integer('total_jobs'); $table->integer('pending_jobs'); $table->integer('failed_jobs'); - $table->text('failed_job_ids'); + $table->longtext('failed_job_ids'); $table->mediumText('options')->nullable(); $table->integer('cancelled_at')->nullable(); $table->integer('created_at'); From b6c9699efa9300cc7d91f1d0ff161a93dec9ca86 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 12 Dec 2022 09:14:05 -0600 Subject: [PATCH 2/4] Update batches.stub --- src/Illuminate/Queue/Console/stubs/batches.stub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Queue/Console/stubs/batches.stub b/src/Illuminate/Queue/Console/stubs/batches.stub index 12b99d23081e..c3ff23179138 100644 --- a/src/Illuminate/Queue/Console/stubs/batches.stub +++ b/src/Illuminate/Queue/Console/stubs/batches.stub @@ -19,7 +19,7 @@ return new class extends Migration $table->integer('total_jobs'); $table->integer('pending_jobs'); $table->integer('failed_jobs'); - $table->longtext('failed_job_ids'); + $table->longText('failed_job_ids'); $table->mediumText('options')->nullable(); $table->integer('cancelled_at')->nullable(); $table->integer('created_at'); From 82f9a811c2baf773fc78c153c7cefe8440acc47b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ribeiro?= Date: Tue, 13 Dec 2022 18:32:33 +0000 Subject: [PATCH 3/4] Fixed Lack of Memory when failing a job Added validation to ensure that the $exception is a Throwable instance or is null, because if we pass another type of variable in the fail() method, the fail method enters an infinite loop until the php process crashes due to lack of memory --- src/Illuminate/Queue/InteractsWithQueue.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Queue/InteractsWithQueue.php b/src/Illuminate/Queue/InteractsWithQueue.php index f7c28fd0605d..6d75e943d29f 100644 --- a/src/Illuminate/Queue/InteractsWithQueue.php +++ b/src/Illuminate/Queue/InteractsWithQueue.php @@ -43,8 +43,15 @@ public function delete() */ public function fail($exception = null) { - if ($this->job) { - $this->job->fail($exception); + //Check if $exception is an instance of \Throwable or if it is null + if($exception instanceof \Throwable || is_null($exception)){ + //If it is, then we can use the fail() method + if ($this->job) { + return $this->job->fail($exception); + } + } else { + //If it is not, then we throw an exception + throw new \Exception('The fail() method requires an instance of \Throwable'); } } From 10e173b7a24d2cf2ba9dca1033b2e617e67f4220 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 13 Dec 2022 15:49:26 -0600 Subject: [PATCH 4/4] Update InteractsWithQueue.php --- src/Illuminate/Queue/InteractsWithQueue.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Illuminate/Queue/InteractsWithQueue.php b/src/Illuminate/Queue/InteractsWithQueue.php index 6d75e943d29f..120a22458e03 100644 --- a/src/Illuminate/Queue/InteractsWithQueue.php +++ b/src/Illuminate/Queue/InteractsWithQueue.php @@ -3,6 +3,8 @@ namespace Illuminate\Queue; use Illuminate\Contracts\Queue\Job as JobContract; +use InvalidArgumentException; +use Throwable; trait InteractsWithQueue { @@ -43,15 +45,12 @@ public function delete() */ public function fail($exception = null) { - //Check if $exception is an instance of \Throwable or if it is null - if($exception instanceof \Throwable || is_null($exception)){ - //If it is, then we can use the fail() method + if ($exception instanceof Throwable || is_null($exception)) { if ($this->job) { return $this->job->fail($exception); } } else { - //If it is not, then we throw an exception - throw new \Exception('The fail() method requires an instance of \Throwable'); + throw new InvalidArgumentException('The fail method requires an instance of Throwable.'); } }