diff --git a/src/Illuminate/Bus/Batch.php b/src/Illuminate/Bus/Batch.php index 45a9290a116d..e08b4a975ae4 100644 --- a/src/Illuminate/Bus/Batch.php +++ b/src/Illuminate/Bus/Batch.php @@ -346,6 +346,14 @@ public function recordFailedJob(string $jobId, $e) $this->cancel(); } + if ($this->hasProgressCallbacks() && $this->allowsFailures()) { + $batch = $this->fresh(); + + collect($this->options['progress'])->each(function ($handler) use ($batch, $e) { + $this->invokeHandlerCallback($handler, $batch, $e); + }); + } + if ($counts->failedJobs === 1 && $this->hasCatchCallbacks()) { $batch = $this->fresh(); diff --git a/tests/Bus/BusBatchTest.php b/tests/Bus/BusBatchTest.php index 8db463cd8ad5..e6137c93843b 100644 --- a/tests/Bus/BusBatchTest.php +++ b/tests/Bus/BusBatchTest.php @@ -250,6 +250,7 @@ public function test_failed_jobs_can_be_recorded_while_not_allowing_failures() $this->assertTrue($batch->finished()); $this->assertTrue($batch->cancelled()); $this->assertEquals(1, $_SERVER['__finally.count']); + $this->assertEquals(0, $_SERVER['__progress.count']); $this->assertEquals(1, $_SERVER['__catch.count']); $this->assertSame('Something went wrong.', $_SERVER['__catch.exception']->getMessage()); } @@ -291,6 +292,7 @@ public function test_failed_jobs_can_be_recorded_while_allowing_failures() $this->assertFalse($batch->finished()); $this->assertFalse($batch->cancelled()); $this->assertEquals(1, $_SERVER['__catch.count']); + $this->assertEquals(2, $_SERVER['__progress.count']); $this->assertSame('Something went wrong.', $_SERVER['__catch.exception']->getMessage()); }