8000 5.6 - database queue wrap transactions, code cleaning · laravel/framework@c38ee67 · GitHub
[go: up one dir, main page]

Skip to content

Commit c38ee67

Browse files
committed
5.6 - database queue wrap transactions, code cleaning
- pop() transaction wrapped in closure for easier readability, removing side effect of marshalJob() which nonintuitively commits the transaction
1 parent 24c4482 commit c38ee67

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

src/Illuminate/Queue/DatabaseQueue.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Illuminate\Queue;
44

5-
use Throwable;
65
use Illuminate\Support\Carbon;
76
use Illuminate\Database\Connection;
87
use Illuminate\Queue\Jobs\DatabaseJob;
@@ -191,19 +190,13 @@ public function pop($queue = null)
191190
{
192191
$queue = $this->getQueue($queue);
193192

194-
try {
195-
$this->database->beginTransaction();
196-
193+
return $this->database->transaction(function () use ($queue) {
197194
if ($job = $this->getNextAvailableJob($queue)) {
198195
return $this->marshalJob($queue, $job);
199196
}
200197

201-
$this->database->commit();
202-
} catch (Throwable $e) {
203-
$this->database->rollBack();
204-
205-
throw $e;
206-
}
198+
return null;
199+
});
207200
}
208201

209202
/**
@@ -267,8 +260,6 @@ protected function marshalJob($queue, $job)
267260
{
268261
$job = $this->markJobAsReserved($job);
269262

270-
$this->database->commit();
271-
272263
return new DatabaseJob(
273264
$this->container, $this, $job, $this->connectionName, $queue
274265
);

0 commit comments

Comments
 (0)
0