Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
vatsake committed Jun 18, 2024
1 parent 710e72d commit 187bce4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion config/octane.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Laravel\Octane\Listeners\FlushTemporaryContainerInstances;
use Laravel\Octane\Listeners\FlushUploadedFiles;
use Laravel\Octane\Listeners\ReportException;
use Laravel\Octane\Listeners\RollbackActiveTransactions;
use Laravel\Octane\Listeners\StopWorkerIfNecessary;
use Laravel\Octane\Octane;

Expand Down Expand Up @@ -77,7 +78,7 @@
],

RequestHandled::class => [
//
RollbackActiveTransactions::class
],

RequestTerminated::class => [
Expand Down
20 changes: 20 additions & 0 deletions src/Listeners/RollbackActiveTransactions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Laravel\Octane\Listeners;

use Illuminate\Support\Facades\DB;

class RollbackActiveTransactions
{
/**
* Handle the event.
*
* @param mixed $event
*/
public function handle($event): void
{
if (class_exists(DB::class) && DB::getPdo()->inTransaction()) {
DB::getPdo()->rollBack();
}
}
}

0 comments on commit 187bce4

Please sign in to comment.