Skip to content

Commit

Permalink
[11.x] Add Illuminate\Bus\BatchRepository::rollBack() contract. (#4…
Browse files Browse the repository at this point in the history
…9176)

Introduced #48961 (minor release for Laravel 10).

Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone authored Nov 29, 2023
1 parent 8725dff commit 059759a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
10 changes: 7 additions & 3 deletions src/Illuminate/Bus/BatchRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

use Closure;

/**
* @method void rollBack()
*/
interface BatchRepository
{
/**
Expand Down Expand Up @@ -92,4 +89,11 @@ public function delete(string $batchId);
* @return mixed
*/
public function transaction(Closure $callback);

/**
* Rollback the last database transaction for the connection.
*
* @return void
*/
public function rollBack();
}
10 changes: 4 additions & 6 deletions src/Illuminate/Queue/Jobs/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,10 @@ public function fail($e = null)
in_array(Batchable::class, class_uses_recursive($commandName))) {
$batchRepository = $this->resolve(BatchRepository::class);

if (method_exists($batchRepository, 'rollBack')) {
try {
$batchRepository->rollBack();
} catch (Throwable $e) {
// ...
}
try {
$batchRepository->rollBack();
} catch (Throwable $e) {
// ...
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/Illuminate/Support/Testing/Fakes/BatchRepositoryFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,14 @@ public function transaction(Closure $callback)
{
return $callback();
}

/**
* Rollback the last database transaction for the connection.
*
* @return void
*/
public function rollBack()
{
//
}
}

0 comments on commit 059759a

Please sign in to comment.