Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jul 21, 2022
2 parents 2999838 + 1b3b06e commit a1944cd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 58 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Application extends Container implements ApplicationContract, CachesConfig
*
* @var string
*/
const VERSION = '9.21.4';
const VERSION = '9.21.5';

/**
* The base path for the Laravel installation.
Expand Down
20 changes: 3 additions & 17 deletions src/Illuminate/Queue/SyncQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

class SyncQueue extends Queue implements QueueContract
{
protected $jobsCount = 0;

/**
* Get the size of the queue.
*
Expand All @@ -39,8 +37,6 @@ public function push($job, $data = '', $queue = null)
{
$queueJob = $this->resolveJob($this->createPayload($job, $queue, $data), $queue);

$this->jobsCount++;

try {
$this->raiseBeforeJobEvent($queueJob);

Expand All @@ -49,8 +45,6 @@ public function push($job, $data = '', $queue = null)
$this->raiseAfterJobEvent($queueJob);
} catch (Throwable $e) {
$this->handleException($queueJob, $e);
} finally {
$this->jobsCount--;
}

return 0;
Expand Down Expand Up @@ -119,19 +113,11 @@ protected function raiseExceptionOccurredJobEvent(Job $job, Throwable $e)
*/
protected function handleException(Job $queueJob, Throwable $e)
{
static $isGuarded = false;

if ($isGuarded) {
$isGuarded = false;
} else {
$isGuarded = $this->jobsCount > 1;
$this->raiseExceptionOccurredJobEvent($queueJob, $e);

$this->raiseExceptionOccurredJobEvent($queueJob, $e);
$queueJob->fail($e);

$queueJob->fail($e);

throw $e;
}
throw $e;
}

/**
Expand Down
44 changes: 4 additions & 40 deletions tests/Integration/Queue/JobChainingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class JobChainingTest extends TestCase
{
public static $catchCallbackCount = 0;
public static $catchCallbackRan = false;

protected function getEnvironmentSetUp($app)
{
Expand All @@ -31,6 +31,7 @@ protected function tearDown(): void
JobChainingTestFirstJob::$ran = false;
JobChainingTestSecondJob::$ran = false;
JobChainingTestThirdJob::$ran = false;
static::$catchCallbackRan = false;
}

public function testJobsCanBeChainedOnSuccess()
Expand Down Expand Up @@ -148,56 +149,19 @@ public function testThirdJobIsNotFiredIfSecondFails()

public function testCatchCallbackIsCalledOnFailure()
{
self::$catchCallbackCount = 0;

Bus::chain([
new JobChainingTestFirstJob,
new JobChainingTestFailingJob,
new JobChainingTestSecondJob,
])->catch(static function () {
self::$catchCallbackCount++;
self::$catchCallbackRan = true;
})->dispatch();

$this->assertTrue(JobChainingTestFirstJob::$ran);
$this->assertSame(1, static::$catchCallbackCount);
$this->assertTrue(static::$catchCallbackRan);
$this->assertFalse(JobChainingTestSecondJob::$ran);
}

public function testCatchCallbackIsCalledOnceOnSyncQueue()
{
self::$catchCallbackCount = 0;

try {
Bus::chain([
new JobChainingTestFirstJob(),
new JobChainingTestThrowJob(),
new JobChainingTestSecondJob(),
])->catch(function () {
self::$catchCallbackCount++;
})->onConnection('sync')->dispatch();
} finally {
$this->assertTrue(JobChainingTestFirstJob::$ran);
$this->assertSame(1, static::$catchCallbackCount);
$this->assertFalse(JobChainingTestSecondJob::$ran);
}

self::$catchCallbackCount = 0;

try {
Bus::chain([
new JobChainingTestFirstJob(),
new JobChainingTestThrowJob(),
new JobChainingTestSecondJob(),
])->catch(function () {
self::$catchCallbackCount++;
})->onConnection('sync')->dispatch();
} finally {
$this->assertTrue(JobChainingTestFirstJob::$ran);
$this->assertSame(1, static::$catchCallbackCount);
$this->assertFalse(JobChainingTestSecondJob::$ran);
}
}

public function testChainJobsUseSameConfig()
{
JobChainingTestFirstJob::dispatch()->allOnQueue('some_queue')->allOnConnection('sync1')->chain([
Expand Down

0 comments on commit a1944cd

Please sign in to comment.